2015-04-20 22:39:35 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.externalevents;
|
2015-02-08 23:53:40 +01:00
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2015-05-12 06:28:11 +02:00
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2015-02-08 23:53:40 +01:00
|
|
|
|
2015-08-04 01:01:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService;
|
2015-04-20 22:39:35 +02:00
|
|
|
|
2015-02-08 23:53:40 +01:00
|
|
|
public class MusicPlaybackReceiver extends BroadcastReceiver {
|
2015-05-12 06:28:11 +02:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(MusicPlaybackReceiver.class);
|
2015-02-08 23:53:40 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
String artist = intent.getStringExtra("artist");
|
|
|
|
String album = intent.getStringExtra("album");
|
|
|
|
String track = intent.getStringExtra("track");
|
|
|
|
|
2015-05-12 06:28:11 +02:00
|
|
|
LOG.info("Current track: " + artist + ", " + album + ", " + track);
|
2015-02-08 23:53:40 +01:00
|
|
|
|
2015-08-04 01:01:14 +02:00
|
|
|
Intent startIntent = new Intent(context, DeviceCommunicationService.class);
|
|
|
|
startIntent.setAction(DeviceCommunicationService.ACTION_SETMUSICINFO);
|
2015-02-08 23:53:40 +01:00
|
|
|
startIntent.putExtra("music_artist", artist);
|
|
|
|
startIntent.putExtra("music_album", album);
|
|
|
|
startIntent.putExtra("music_track", track);
|
|
|
|
context.startService(startIntent);
|
|
|
|
}
|
|
|
|
}
|