android-在活动中实施的自定义权限,并已添加为意图过滤器
作者:互联网
我已经阅读并检查了如何在网上和书籍上执行此操作,但是在Note 3上无法使用.这就是我所做的.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hardkore.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="18" />
<permission
android:name="com.hardkore.permissions.MY_PERMISSION"
android:protectionLevel="dangerous"
android:label="@string/perm_label"
android:description="@string/perm_desc" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:permission="com.hardkore.permissions.MY_PERMISSION"
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.hardkore.permissions.MY_PERMISSION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
这是logcat显示的错误
02-15 16:21:32.525: W/ActivityManager(807): mDVFSHelper.acquire()
02-15 16:21:32.525: W/ActivityManager(807): Permission Denial: starting Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.hardkore.testapp/.MainActivity
}
from null (pid=28305, uid=2000) requires com.hardkore.permissions.MY_PERMISSION
02-15 16:21:35.525: W/ActivityManager(807): mDVFSHelper.release()
解决方法:
在清单文件中声明自定义权限后,还应该声明您的应用程序正在使用此权限.这似乎是多余的,但是对我有用.
<permission
android:name="com.hardkore.permissions.MY_PERMISSION"
android:protectionLevel="dangerous"
android:label="@string/perm_label"
android:description="@string/perm_desc" />
<uses-permission android:name="com.hardkore.permissions.MY_PERMISSION"/>
标签:android-permissions,android 来源: https://codeday.me/bug/20191122/2057127.html