如何获得android.Manifest.permission.MEDIA_CONTENT_CONTROL的android权限 [英] How to get android permission of android.Manifest.permission.MEDIA_CONTENT_CONTROL

查看:1447
本文介绍了如何获得android.Manifest.permission.MEDIA_CONTENT_CONTROL的android权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用API​​21中的MediaSessionManager来控制设备上的音乐播放. 对于用法,它表示需要保存android.Manifest.permission.MEDIA_CONTENT_CONTROL:

i am trying to use MediaSessionManager in API21, to control the music play on the device. For the usage, it says need to held the android.Manifest.permission.MEDIA_CONTENT_CONTROL:

public void addOnActiveSessionsChangedListener (MediaSessionManager.OnActiveSessionsChangedListener sessionListener, ComponentName notificationListener, Handler handler)

Added in API level 21
Add a listener to be notified when the list of active sessions changes.***This requires the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by the calling app.*** You may also retrieve this list if your app is an enabled notification listener using the NotificationListenerService APIs, in which case you must pass the ComponentName of your enabled listener. Updates will be posted to the handler specified or to the caller's thread if the handler is null.

我没有通知服务.但是,通过在AndroidManifest.xml中添加<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"/>,并使用PackageManager.PERMISSION_GRANTED == context.checkCallingOrSelfPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL)检查代码中的权限 它始终返回false,并且该应用程序将因安全异常而崩溃.

I don't have a notification service. But by adding the <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"/> in AndroidManifest.xml, and check the permission in code with PackageManager.PERMISSION_GRANTED == context.checkCallingOrSelfPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) it returns false always, and the app will crash with security exception.

如何正确获得许可?我查看了权限介绍,

How to get the permission correctly? i check the permission introduction,

public static final String MEDIA_CONTENT_CONTROL

Added in API level 19
Allows an application to know what content is playing and control its playback.

***Not for use by third-party applications due to privacy of media consumption***

Constant Value: "android.permission.MEDIA_CONTENT_CONTROL"

不供第三方应用程序使用"是否使权限有所不同,而普通应用程序却无法获得该权限?

Is the "Not for use by third-party applications" makes the permission different, and common application can't get it?

推荐答案

不幸的是,此权限仅限于系统应用程序(属于系统映像的应用程序)或属于设备供应商的应用程序(即.应用签名必须与平台的签名相同).因此,对于第三方应用程序,这是不允许的.

Unfortunately, this permission is only restricted to either system apps(apps which are part of system image) or the apps which belongs to the vendor the device (ie. app signature must be same as platform's). So for third party apps this is not allowed.

这篇关于如何获得android.Manifest.permission.MEDIA_CONTENT_CONTROL的android权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆