[Android] Set mediasession button receiver in controller

Geoffrey Métais git at videolan.org
Fri Mar 31 10:16:01 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 31 10:14:07 2017 +0200| [4c7444879178e3ed3fcbbb18d78300ac9171f81c] | committer: Geoffrey Métais

Set mediasession button receiver in controller

Otherway, it crashes on Kitkat

> https://code.videolan.org/videolan/vlc-android/commit/4c7444879178e3ed3fcbbb18d78300ac9171f81c
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 3e8ed5e..858ef0a 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1072,13 +1072,13 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
         mediaButtonIntent.setClass(this, RemoteControlClientReceiver.class);
         PendingIntent mbrIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0);
+        ComponentName mbrName = new ComponentName(this, RemoteControlClientReceiver.class);
 
         mSessionCallback = new MediaSessionCallback();
-        mMediaSession = new MediaSessionCompat(this, "VLC");
+        mMediaSession = new MediaSessionCompat(this, "VLC", mbrName, mbrIntent);
         mMediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS
                 | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
         mMediaSession.setCallback(mSessionCallback);
-        mMediaSession.setMediaButtonReceiver(mbrIntent);
         try {
             mMediaSession.setActive(true);
         } catch (NullPointerException e) {



More information about the Android mailing list