How to get the package name of music player when the broadcast receiver calls the application. i used set of playsate and metachanged broadcast reciver to get the rid of music player. i need to get the package name of music player which i currently playing. I am not sure this would be possible. if anyone having idea, please share with me.
You can get the currently active package name and activity name using the following code,
List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(1);
Log.d("topActivity", "CURRENT Activity ::"
+ taskInfo.get(0).topActivity.getClassName());
ComponentName componentInfo = taskInfo.get(0).topActivity;
Log.d("topActivity", "CURRENT Package ::"
+ componentInfo.getPackageName());
or
if(isMusicActive().equalsto(true))
{
public static String PACKAGE_NAME = getApplicationContext().getPackageName();
// get package name of player.
}