Reputation: 155
I'm currently using a method similar to the one below to retrieve the information, however I am not sure how I can obtain the genre. Does anyone know what the string extra is called for genre or if there is an extra at all? Thanks.
Track info of currently playing music
public class CurrentMusicTrackInfoActivity extends Activity
{
public static final String SERVICECMD = "com.android.music.musicservicecommand";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
com.sec.android.app.music.player.service.CorePlayerService
IntentFilter iF = new IntentFilter();
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);
}
private BroadcastReceiver mReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
String cmd = intent.getStringExtra("command");
Log.v("tag ", action + " / " + cmd);
String artist = intent.getStringExtra("artist");
String album = intent.getStringExtra("album");
String track = intent.getStringExtra("track");
Log.v("tag",artist+":"+album+":"+track);
Toast.makeText(CurrentMusicTrackInfoActivity.this,track,Toast.LENGTH_SHORT).show();
}
};
}
Upvotes: 0
Views: 4331
Reputation: 155
It turns out there is no genre extra passed, just the 3 above and id. I was able to see the extras passed using the following code:
Bundle b = intent.getExtras();
Set<String> set = b.keySet();
Iterator it = set.iterator();
while(it.hasNext()==true){
Toast.makeText(getApplicationContext(),""+it.next(), Toast.LENGTH_SHORT).show();
}
Upvotes: 3