-2

I am writing an app to log down all the music the user has listened to. I am wondering if there is some way I can know the title of the current playing music in the Android phone? Thanks!

4

1 回答 1

0
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");

String artist = intent.getStringExtra("artist");
String album = intent.getStringExtra("album");
String track = intent.getStringExtra("track");


}
};

}

你可以在这里得到完整的答案。

希望能帮助到你!!

于 2013-09-17T04:29:54.103 回答