Android homescreen shortcut permission error

青春壹個敷衍的年華 提交于 2019-12-05 01:23:47

I had something like this happen when I had accidentally duplicated the activity tag for one of my activities in my manifest. I had something like this in my application section.

<activity android:name=".ConventionHome" android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity android:name="ConventionHome"></activity>

When I removed the second activity tag, things started working normally.

Figured it out, added this under <activity> tag of activity:

<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>

Something like this should work:

<intent-filter>
    <action android:name="com.example.Project.Action"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter> 

inside of the Activity declaration in the manifest.

staktrace

I ran into this problem too, and it turned out it was because the Activity wasn't exposed to other processes. I had to add the android:exported="true" attribute to the activity tag in my manifest.

See http://developer.android.com/guide/topics/manifest/activity-element.html#exported for more information.

I haven't run into this personally but I did do some research and found the following.

Apparently whatever is attempting to invoke your app or if your app has a call to create an intent and start an activity of some intent the UID is not the same.

In ActivityManagerServer.java there are below judgement in it.

int checkComponentPermission(String permission, int pid, int uid, int reqUid)
// If the target requires a specific UID, always fail for others.
   if (reqUid >= 0 && uid != reqUid) {
       return PackageManager.PERMISSION_DENIED;
   }

I'm going to do some testing on this and see if I can reproduce this in a test application and provide any additional feedback.

Make sure you are only trying to invoke publicly exposed activities through any intents.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!