mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-17 07:29:27 +01:00
a1cb246e27
Previously, the DeviceCommunicationService was invoked directly, via Intent intent = new Intent(foo, bar); intent.setExtra(EXTRA_BAZ, baz); startService(...); and this was scattered throughout GadgetBridge. Now there is a "frontend" available, so that you can call the service more easily, like GBApplication.deviceService().connect(); For a start, this client interface (DeviceService) actually implements the same interface (EventHandler) as the receiving side (DeviceSupport). This may change in the future. This will also make testing much easier, because we can use this client interface to invoke the test service as well.
26 lines
845 B
Java
26 lines
845 B
Java
package nodomain.freeyourgadget.gadgetbridge.externalevents;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
|
|
public class MusicPlaybackReceiver extends BroadcastReceiver {
|
|
private static final Logger LOG = LoggerFactory.getLogger(MusicPlaybackReceiver.class);
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
String artist = intent.getStringExtra("artist");
|
|
String album = intent.getStringExtra("album");
|
|
String track = intent.getStringExtra("track");
|
|
|
|
LOG.info("Current track: " + artist + ", " + album + ", " + track);
|
|
|
|
GBApplication.deviceService().onSetMusicInfo(artist, album, track);
|
|
}
|
|
}
|