Android: java.lang.SecurityException: Permission Denial: start Intent


I have created an application containing GWVectraNotifier activity which is called from other applications to display Notification.

In the Notification dialog, there will be 'show' button and 'close' button.

Onclick of 'show' button, the corresponding activity will be started.

To check the functionality of the above application,

I started the GWVectraNotifier activity from K9Mail application on checkmail event trigger.

I am able to start the GWVectraNotifier activity successfully, but onclick of 'show' button i will have to start 'MessageList' activity of K9mail.To do so, i wrote the below code:

Intent i = new Intent();
i.setComponent(new ComponentName("com.fsck.k9", "com.fsck.k9.activity.MessageList"));
i.putExtra("account", accUuid);
i.putExtra("folder", accFolder);

which throws :

WARN/ActivityManager(59): Permission denied: checkComponentPermission() reqUid=10050
WARN/ActivityManager(59): Permission Denial: starting Intent { cmp=com.fsck.k9/.activity.MessageList (has extras) } from ProcessRecord{43f6d7c8 675:com.i10n.notifier/10052} (pid=675, uid=10052) requires null
WARN/System.err(675): java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.fsck.k9/.activity.MessageList (has extras) } from ProcessRecord{43f6d7c8 675:com.i10n.notifier/10052} (pid=675, uid=10052) requires null
WARN/System.err(675):     at android.os.Parcel.readException(
WARN/System.err(675):     at android.os.Parcel.readException(
WARN/System.err(675):     at
WARN/System.err(675):     at
WARN/System.err(675):     at
WARN/System.err(675):     at
WARN/System.err(675):     at com.i10n.notifier.GWVectraNotifier$2$
WARN/System.err(675):     at
WARN/System.err(675):     at com.i10n.notifier.GWVectraNotifier$2.onClick(
WARN/System.err(675):     at android.view.View.performClick(
WARN/System.err(675):     at android.view.View$
WARN/System.err(675):     at android.os.Handler.handleCallback(
WARN/System.err(675):     at android.os.Handler.dispatchMessage(
WARN/System.err(675):     at android.os.Looper.loop(
WARN/System.err(675):     at
WARN/System.err(675):     at java.lang.reflect.Method.invokeNative(Native Method)
WARN/System.err(675):     at java.lang.reflect.Method.invoke(
WARN/System.err(675):     at$
WARN/System.err(675):     at
WARN/System.err(675):     at dalvik.system.NativeStart.main(Native Method)

Actually i am not able to understand what permissions to include in my Notifier application's manifest file to access MessageList of k9Mail. I am pasting below the permissions included in k9mail application's manifest file:

<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.READ_OWNER_DATA"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name=""/>
<permission android:name="com.fsck.k9.permission.READ_ATTACHMENT"
<uses-permission android:name="com.fsck.k9.permission.READ_ATTACHMENT"/>
<permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"
<uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
<permission android:name="com.fsck.k9.permission.READ_MESSAGES"
<uses-permission android:name="com.fsck.k9.permission.READ_MESSAGES"/>
<permission android:name="com.fsck.k9.permission.DELETE_MESSAGES"
<uses-permission android:name="com.fsck.k9.permission.DELETE_MESSAGES"/>           

Can some one tell me which permission to include in my app? In the above permissions some are only for k9mail , because those are the permission classes written for k9. So, i will only be able to include the built-in permissions of android in the above given permissions. I tried by doing so as well, but it didn't solve my issue :(

2/2/2011 7:51:03 PM

You have to add android:exported="true" in the manifest file in the activity you are trying to start.

From the android:exported documentation:

Whether or not the activity can be launched by components of other applications — "true" if it can be, and "false" if not. If "false", the activity can be launched only by components of the same application or applications with the same user ID.

The default value depends on whether the activity contains intent filters. The absence of any filters means that the activity can be invoked only by specifying its exact class name. This implies that the activity is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the activity is intended for external use, so the default value is "true".

This attribute is not the only way to limit an activity's exposure to other applications. You can also use a permission to limit the external entities that can invoke the activity (see the permission attribute).

8/2/2013 6:14:42 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow