User Permission Enforced and Added as a Job Filter

I read and checked how to do this online and from books, but it will not work in my note 3. This is what I did.

<?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>

this is the error displayed by 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()
+3
source share
4 answers

After the user permission is declared in the manifest file, you must also state that your application uses this permission. It seems redundant, but it worked for me.

<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"/>
+3
source

you should avoid defining user permissions for your main action. The Android framework does not have this permission, and as a result, it will not be able to execute it.

0
source

Applying user permissions to your main launch activity ... How can an android start this activity now? Remove user permission or perform another basic action.

0
source

try to trigger activity like

            Intent intent = new Intent();
            intent .setAction("com.hardkore.permissions.MY_PERMISSION");
            intent .addCategory("android.intent.category.DEFAULT");
            startActivity(intent );

And do not forget to add permission to another application, for example

<uses-permission android:name="com.hardkore.permissions.MY_PERMISSION"/>
0
source

All Articles