-2

How restore all(or almost) session data of users activity by media controller(android.media.session.MediaController). at least Youtube and GP Music?

I can`t get pending intent from media controller for GPMusic (null). Intent from Youtube can restore only home screen(I wanna restore video and position)

List<MediaController> list = mgr.getActiveSessions(new ComponentName(getApplicationContext().getPackageName(), TestService.class.getName()));
...
PendingIntent pIntent = currentController.getSessionActivity() 
pIntent.send();
sergii.gudym
  • 163
  • 1
  • 13

1 Answers1

0

This is discussed on the Android TV Developers community. Check out this post: https://plus.google.com/u/1/110913444113360071708/posts/HDs8UsyQwxL

From the MediaController you can get the Session activity to launch into the app. If you are not seeing it, then the app is not using MediaSession correctly, you can just launch the app using the package name. You can get the package name from the controller as well: mediaSessionController.getPackageName()

If you implemented OnActivieSessionsChangedListener correctly (which it sounds like you have if you made it this far) then the rest is dependent on the apps properly maintaining and updating their MediaSessions. Sadly, there are a lot of apps that do not maintain their MediaSession 100% correctly. It is possible that they do not update their metadata, playback state, or even not unregister their session correctly. Each app may act differently depending on how much they invested into MediaSession.

Community
  • 1
  • 1
Benjamin
  • 250
  • 1
  • 9