Missing permission to control media error on Android 5/L
在Android 5/L上缺少控制媒体错误的权限。
Got the below error on this line while trying to setup a RemoteController. I couldn't find any info on this error so wanted to post the error and the simple solution.
在尝试设置RemoteController时,在这一行上得到了下面的错误。我找不到任何关于这个错误的信息,所以想发布错误和简单的解决方案。
Code that triggered it:
代码触发:
if(!((AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE)).registerRemoteController(mRemoteController)) {...}
Error:
错误:
E/AndroidRuntime(21073): FATAL EXCEPTION: main
E/AndroidRuntime(21073): Process: com.example.widgetdemo, PID: 21073
E/AndroidRuntime(21073): java.lang.SecurityException: Missing permission to control media.
E/AndroidRuntime(21073): at android.os.Parcel.readException(Parcel.java:1540)
E/AndroidRuntime(21073): at android.os.Parcel.readException(Parcel.java:1493)
E/AndroidRuntime(21073): at android.media.session.ISessionManager$Stub$Proxy.addSessionsListener(ISessionManager.java:274)
E/AndroidRuntime(21073): at android.media.session.MediaSessionManager.addOnActiveSessionsChangedListener(MediaSessionManager.java:208)
E/AndroidRuntime(21073): at android.media.RemoteController.startListeningToSessions(RemoteController.java:796)
E/AndroidRuntime(21073): at android.media.AudioManager.registerRemoteController(AudioManager.java:2530)
E/AndroidRuntime(21073): at com.example.widgetdemo.RemoteControlService.setRemoteControllerEnabled(RemoteControlService.java:68)
E/AndroidRuntime(21073): at com.example.widgetdemo.MainActivity$3.onServiceConnected(MainActivity.java:216)
E/AndroidRuntime(21073): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1203)
E/AndroidRuntime(21073): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1220)
1 个解决方案
#1
2
User needs to explicitly give your app Notification access permission, by going to Settings -> Sound & Notification -> Notification access -> Select checkbox next to your app
用户需要明确地给你的应用程序通知访问权限,通过设置-> Sound & Notification ->通知access ->在你的应用程序旁边选择复选框。
#1
2
User needs to explicitly give your app Notification access permission, by going to Settings -> Sound & Notification -> Notification access -> Select checkbox next to your app
用户需要明确地给你的应用程序通知访问权限,通过设置-> Sound & Notification ->通知access ->在你的应用程序旁边选择复选框。