I am trying to move from RemoteController to MediaController for Lollipop but I\'m having trouble getting a MediaController instance. In MediaController it says:
MediaSessionManager.getActiveSessions() gives you a list of MediaController
instances associated with the currently playing music player(s). You can then use MediaController.registerCallback() to register a MediaController.Callback implementation you've created, which has similar callbacks to the deprecated RemoteController.OnClientUpdateListener (or just send media controls directly back to the MediaController
.
Of course, in most cases you want to keep your list of MediaController
s in sync with the system: that is what MediaSessionManager.addOnActiveSessionsChangedListener() is for: it gives you an updated list of MediaController
s with which to use and is called every time the list of players change. As per the documentation, if you are using the permission you can pass null
in for the ComponentName notificationListener
parameter.