Search code examples
androidaudio-playerandroid-music-player

Get currently playing music app


I am using this tutorial and the RemoteController to control the currently playing music player:

http://forum.xda-developers.com/showthread.php?t=2579415

Is there a way to get the application/package of the currently playing music application? I want to be able to open it.

I'm sure it is possible somehow as Aviate manages to do it, but afaict this class does not provide that information:

https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener.html

Maybe there is some unrelated way of getting the currently playing music player...

Thanks :)


Solution

  • I worked it out... had to use reflection on the RemoteController though.

    Method method = mRemoteController.getClass().getDeclaredMethod("getRemoteControlClientPackageName");
    if (method != null) {
        return (String) method.invoke(mRemoteController);
    }