0

I try to use android's mediabrowser and sample by google works fine on phones (https://github.com/googlesamples/android-media-controller)

But on android TV it can't find any app which supported this feature

final Intent mediaBrowserIntent =
                new Intent(MediaBrowserServiceCompat.SERVICE_INTERFACE);
final List<ResolveInfo> services =
                packageManager.queryIntentServices(mediaBrowserIntent,
                        PackageManager.GET_RESOLVED_FILTER);

in services placed only current app

Could you help me get API to collect last used mediadata? I can't find any description or guide for creating TV launcher (which have access to last used or recommended media by another app)

I just wanna GET metadata like https://developer.android.com/training/tv/playback/now-playing.html or http://corochann.com/android-tv-application-hands-on-tutorial-11-277.html

JKshort
  • 143
  • 1
  • 12
sergii.gudym
  • 163
  • 1
  • 13

1 Answers1

1

You can query for all active media sessions using the method MediaSessionManager.getActiveSessions(notificationListnerComponentName) which will return a list of alla ctive mediacontrollers with the most active as the first item in the list. Code sample:

MediaSessionManager mediaSessionManager = context.getSystemService(Context.MEDIA_SESSION_SERVICE);
List<MediaController> activeMediaSessionControllers = mediaSessionManager.getActiveSessions(null);
NIPHIN
  • 1,071
  • 1
  • 8
  • 16
  • java.lang.SecurityException: Missing permission to control media. I can request Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS") in android phone, but most of android tv no supported this intent O_o – sergii.gudym Nov 30 '17 at 08:24
  • If you want to use the active mediacontroller to control the other external apps , the 3rd party apps should allow you to do so. Those apps would be doing this by means of validating your package signature – NIPHIN Nov 30 '17 at 14:58