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!
Asked
Active
Viewed 549 times
-2
-
That seems rather hard to do considering people use several different applications to play/listen to music. – a sandwhich Sep 17 '13 at 04:24
1 Answers
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");
}
};
}
You can get full answer here.
Hope it helps!!

Community
- 1
- 1

Bhoomika Brahmbhatt
- 7,404
- 3
- 29
- 44