mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-11 00:36:32 +02:00
29 lines
1.1 KiB
Java
29 lines
1.1 KiB
Java
package nodomain.freeyourgadget.gadgetbridge.externalevents;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.util.Log;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.BluetoothCommunicationService;
|
|
|
|
public class MusicPlaybackReceiver extends BroadcastReceiver {
|
|
private final String TAG = this.getClass().getSimpleName();
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
String artist = intent.getStringExtra("artist");
|
|
String album = intent.getStringExtra("album");
|
|
String track = intent.getStringExtra("track");
|
|
|
|
Log.i(TAG, "Current track: " + artist + ", " + album + ", " + track);
|
|
|
|
Intent startIntent = new Intent(context, BluetoothCommunicationService.class);
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_SETMUSICINFO);
|
|
startIntent.putExtra("music_artist", artist);
|
|
startIntent.putExtra("music_album", album);
|
|
startIntent.putExtra("music_track", track);
|
|
context.startService(startIntent);
|
|
}
|
|
}
|