问题
What I want to do is to get current playing song data. Song might be on spotify or any other music player. Actually I want to get data which transferred to phone hardware.
- Is it possible ?
- Is there a provided way to do it ?
I've tried, Broadcast Receiver with these filter but onReceived did not invoked. (tested with spotify android app)
IntentFilter iF = new IntentFilter();
iF.addCategory("ComponentInfo");
iF.addCategory("com.spotify.mobile.android.service.SpotifyIntentService");
iF.addCategory("com.spotify.mobile.android.service.SpotifyService");
iF.addAction("com.spotify.mobile.android.ui.widget.SpotifyWidget");
iF.addAction("ComponentInfo");
iF.addAction("com.spotify");
iF.addAction("com.spotify.mobile.android.service.SpotifyIntentService");
iF.addAction("com.spotify.mobile.android.service.SpotifyService");
iF.addAction("com.spotify.mobile.android.queuechanged");
iF.addAction("com.spotify.mobile.android.metadatachanged");
iF.addAction("com.android.music.metachanged");
iF.addAction("com.android.music.playstatechanged");
iF.addAction("com.android.music.playbackcomplete");
iF.addAction("com.android.music.queuechanged");
registerReceiver(mReceiver, iF);
回答1:
As of API 19, you can use RemoteControlClient.OnMetadataUpdateListener.
来源:https://stackoverflow.com/questions/26025711/is-it-possible-to-get-current-playing-song-data-on-android-if-yes-how