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; import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; 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"); /* Bundle bundle = intent.getExtras(); for (String key : bundle.keySet()) { Object value = bundle.get(key); LOG.info(String.format("%s %s (%s)", key, value != null ? value.toString() : "null", value != null ? value.getClass().getName() : "no class")); } */ LOG.info("Current track: " + artist + ", " + album + ", " + track); MusicSpec musicSpec = new MusicSpec(); musicSpec.artist = artist; musicSpec.artist = album; musicSpec.artist = track; GBApplication.deviceService().onSetMusicInfo(musicSpec); } }