Android:. lang。SecurityException:权限拒绝:开始意图

时间:2022-10-11 23:34:00

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

我已经创建了一个包含GWVectraNotifier活动的应用程序,该活动从其他应用程序调用来显示通知。

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

在通知对话框中,会有“显示”按钮和“关闭”按钮。

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

点击“show”按钮,相应的活动就会启动。

To check the functionality of the above application,

要检查上述应用程序的功能,

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

我在checkmail事件触发器上启动了来自K9Mail应用程序的GWVectraNotifier活动。

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:

我可以成功地启动GWVectraNotifier活动,但是单击“show”按钮,我将不得不启动K9mail的“MessageList”活动。为此,我编写了以下代码:

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

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(Parcel.java:1247)
WARN/System.err(675):     at android.os.Parcel.readException(Parcel.java:1235)
WARN/System.err(675):     at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
WARN/System.err(675):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
WARN/System.err(675):     at android.app.Activity.startActivityForResult(Activity.java:2817)
WARN/System.err(675):     at android.app.Activity.startActivity(Activity.java:2923)
WARN/System.err(675):     at com.i10n.notifier.GWVectraNotifier$2$1.run(GWVectraNotifier.java:63)
WARN/System.err(675):     at android.app.Activity.runOnUiThread(Activity.java:3707)
WARN/System.err(675):     at com.i10n.notifier.GWVectraNotifier$2.onClick(GWVectraNotifier.java:53)
WARN/System.err(675):     at android.view.View.performClick(View.java:2408)
WARN/System.err(675):     at android.view.View$PerformClick.run(View.java:8816)
WARN/System.err(675):     at android.os.Handler.handleCallback(Handler.java:587)
WARN/System.err(675):     at android.os.Handler.dispatchMessage(Handler.java:92)
WARN/System.err(675):     at android.os.Looper.loop(Looper.java:123)
WARN/System.err(675):     at android.app.ActivityThread.main(ActivityThread.java:4627)
WARN/System.err(675):     at java.lang.reflect.Method.invokeNative(Native Method)
WARN/System.err(675):     at java.lang.reflect.Method.invoke(Method.java:521)
WARN/System.err(675):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
WARN/System.err(675):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
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:

实际上,我无法理解在我的Notifier应用程序的清单文件中包含哪些权限以访问k9Mail的MessageList。我粘贴在k9mail应用程序清单文件中的权限以下:

<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="org.thialfihar.android.apg.permission.READ_KEY_DETAILS"/>
<permission android:name="com.fsck.k9.permission.READ_ATTACHMENT"
            android:permissionGroup="android.permission-group.MESSAGES"
            android:protectionLevel="dangerous"
            android:label="@string/read_attachment_label"
            android:description="@string/read_attachment_desc"/>
<uses-permission android:name="com.fsck.k9.permission.READ_ATTACHMENT"/>
<permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"
             android:permissionGroup="android.permission-group.MESSAGES"
             android:protectionLevel="dangerous"
             android:label="@string/remote_control_label"
             android:description="@string/remote_control_desc"/>
<uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
<permission android:name="com.fsck.k9.permission.READ_MESSAGES"
            android:permissionGroup="android.permission-group.MESSAGES"
            android:protectionLevel="normal"
            android:label="@string/read_messages_label"
            android:description="@string/read_messages_desc"/>
<uses-permission android:name="com.fsck.k9.permission.READ_MESSAGES"/>
<permission android:name="com.fsck.k9.permission.DELETE_MESSAGES"
            android:permissionGroup="android.permission-group.MESSAGES"
            android:protectionLevel="normal"
            android:label="@string/delete_messages_label"
            android:description="@string/read_messages_desc"/>
<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 :(

谁能告诉我在我的应用中应该包含哪些权限?在上面的权限中,有些只用于k9mail,因为这些是为k9编写的权限类。因此,我只能在上面给定的权限中包含android的内置权限。我也试过了,但并没有解决我的问题

9 个解决方案

#1


151  

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

您必须在要启动的活动的清单文件中添加android:export ="true"。

From the android:exported documentation:

从android:导出的文档:

android:exported
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.

android:导出该活动是否可以由其他应用程序的组件启动——如果可以,则为“true”;如果不能,则为“false”。如果“false”,则只能由具有相同用户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".

默认值取决于活动是否包含意图过滤器。没有任何过滤器意味着只能通过指定活动的确切类名来调用活动。这意味着该活动只用于应用程序内部使用(因为其他人不知道类名)。在这种情况下,默认值是“false”。另一方面,至少有一个过滤器的存在意味着活动是用于外部使用的,因此默认值是“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).

这个属性不是限制活动暴露于其他应用程序的唯一方法。您还可以使用权限来限制可以调用活动的外部实体(请参见权限属性)。

#2


101  

The java.lang.SecurityException you are seeing is because you may enter two entries pointing to the same activity. Remove the second one and you should be good to go.

. lang。您看到的SecurityException是因为您可以输入两个指向相同活动的条目。把第二个拿走,你就可以走了。

More Explanation

You may be declared the activity 2 times in the manifest with different properties, like :

您可以在清单中以不同的属性声明活动2次,例如:

 <activity android:name=".myclass"> </activity>

and

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

You should remove the unwanted one from the manifest

您应该从清单中删除不想要的那个

#3


15  

In your Manifest file write this before </application >

在您的Manifest文件中,在之前编写这个

<activity android:name="com.fsck.k9.activity.MessageList">
   <intent-filter>
      <action android:name="android.intent.action.MAIN">
      </action>
   </intent-filter>
</activity>

and tell me if it solves your issue :)

告诉我它是否能解决你的问题

#4


7  

I had this problem with this exact activity.

我有这个问题。

You can't start com.fsck.k9.activity.MessageList from an external activity.

你不能com.fsck.k9.activity开始。来自外部活动的消息列表。

I solved it with:

我解决了这个问题:

Intent LaunchK9 = getPackageManager().getLaunchIntentForPackage("com.fsck.k9"); this.startActivity(LaunchK9);

意图LaunchK9 = getPackageManager().getLaunchIntentForPackage(“com.fsck.k9”);this.startActivity(LaunchK9);

Using http://developer.android.com/reference/android/content/pm/PackageManager.html

使用http://developer.android.com/reference/android/content/pm/PackageManager.html

#5


6  

I was running into the same issue and wanted to avoid adding the intent filter as you described. After some digging, I found an xml attribute android:exported that you should add to the activity you would like to be called.

我遇到了同样的问题,希望避免添加意图过滤器。在进行了一些挖掘之后,我发现了一个xml属性android:导出您应该添加到您想要调用的活动。

It is by default set to false if no intent filter added to your activity, but if you do have an intent filter it gets set to true.

如果没有添加到活动的意图过滤器,则默认设置为false,但如果有意图过滤器,则将设置为true。

here is the documentation http://developer.android.com/guide/topics/manifest/activity-element.html#exported

下面是http://developer.android.com/guide/topics/manifest/activity-element.html#导出的文档

tl;dr: addandroid:exported="true" to your activity in your AndroidManifest.xml file and avoid adding the intent-filter :)

在您的AndroidManifest中,将="true"导出到您的活动中。xml文件,避免添加意图过滤器:)

#6


1  

Make sure that the component has the "exported" flag set to true. Also the component defining the permission should be installed before the component that uses it.

确保组件将“导出”标志设置为true。定义权限的组件应该在使用权限的组件之前安装。

#7


1  

It's easy maybe you have error in the configuration.

很容易在配置中出现错误。

For Example: Manifest.xml

例如:Manifest.xml

Android:. lang。SecurityException:权限拒绝:开始意图

But in my configuration have for default Activity .Splash

但是在我的配置中有默认的Activity。splash

Android:. lang。SecurityException:权限拒绝:开始意图

you need check this configuration and the file Manifest.xml

您需要检查这个配置和文件Manifest.xml

Good Luck

祝你好运

#8


1  

I solved this exception by changing the target sdk version from 19 onwards kitkat version AndroidManifest.xml.

我通过从kitkat版本的AndroidManifest.xml中修改目标sdk版本19来解决这个异常。

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

#9


0  

My problem was that I had this: Android:. lang。SecurityException:权限拒绝:开始意图 Instead of this: Android:. lang。SecurityException:权限拒绝:开始意图

我的问题是我有:

#1


151  

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

您必须在要启动的活动的清单文件中添加android:export ="true"。

From the android:exported documentation:

从android:导出的文档:

android:exported
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.

android:导出该活动是否可以由其他应用程序的组件启动——如果可以,则为“true”;如果不能,则为“false”。如果“false”,则只能由具有相同用户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".

默认值取决于活动是否包含意图过滤器。没有任何过滤器意味着只能通过指定活动的确切类名来调用活动。这意味着该活动只用于应用程序内部使用(因为其他人不知道类名)。在这种情况下,默认值是“false”。另一方面,至少有一个过滤器的存在意味着活动是用于外部使用的,因此默认值是“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).

这个属性不是限制活动暴露于其他应用程序的唯一方法。您还可以使用权限来限制可以调用活动的外部实体(请参见权限属性)。

#2


101  

The java.lang.SecurityException you are seeing is because you may enter two entries pointing to the same activity. Remove the second one and you should be good to go.

. lang。您看到的SecurityException是因为您可以输入两个指向相同活动的条目。把第二个拿走,你就可以走了。

More Explanation

You may be declared the activity 2 times in the manifest with different properties, like :

您可以在清单中以不同的属性声明活动2次,例如:

 <activity android:name=".myclass"> </activity>

and

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

You should remove the unwanted one from the manifest

您应该从清单中删除不想要的那个

#3


15  

In your Manifest file write this before </application >

在您的Manifest文件中,在之前编写这个

<activity android:name="com.fsck.k9.activity.MessageList">
   <intent-filter>
      <action android:name="android.intent.action.MAIN">
      </action>
   </intent-filter>
</activity>

and tell me if it solves your issue :)

告诉我它是否能解决你的问题

#4


7  

I had this problem with this exact activity.

我有这个问题。

You can't start com.fsck.k9.activity.MessageList from an external activity.

你不能com.fsck.k9.activity开始。来自外部活动的消息列表。

I solved it with:

我解决了这个问题:

Intent LaunchK9 = getPackageManager().getLaunchIntentForPackage("com.fsck.k9"); this.startActivity(LaunchK9);

意图LaunchK9 = getPackageManager().getLaunchIntentForPackage(“com.fsck.k9”);this.startActivity(LaunchK9);

Using http://developer.android.com/reference/android/content/pm/PackageManager.html

使用http://developer.android.com/reference/android/content/pm/PackageManager.html

#5


6  

I was running into the same issue and wanted to avoid adding the intent filter as you described. After some digging, I found an xml attribute android:exported that you should add to the activity you would like to be called.

我遇到了同样的问题,希望避免添加意图过滤器。在进行了一些挖掘之后,我发现了一个xml属性android:导出您应该添加到您想要调用的活动。

It is by default set to false if no intent filter added to your activity, but if you do have an intent filter it gets set to true.

如果没有添加到活动的意图过滤器,则默认设置为false,但如果有意图过滤器,则将设置为true。

here is the documentation http://developer.android.com/guide/topics/manifest/activity-element.html#exported

下面是http://developer.android.com/guide/topics/manifest/activity-element.html#导出的文档

tl;dr: addandroid:exported="true" to your activity in your AndroidManifest.xml file and avoid adding the intent-filter :)

在您的AndroidManifest中,将="true"导出到您的活动中。xml文件,避免添加意图过滤器:)

#6


1  

Make sure that the component has the "exported" flag set to true. Also the component defining the permission should be installed before the component that uses it.

确保组件将“导出”标志设置为true。定义权限的组件应该在使用权限的组件之前安装。

#7


1  

It's easy maybe you have error in the configuration.

很容易在配置中出现错误。

For Example: Manifest.xml

例如:Manifest.xml

Android:. lang。SecurityException:权限拒绝:开始意图

But in my configuration have for default Activity .Splash

但是在我的配置中有默认的Activity。splash

Android:. lang。SecurityException:权限拒绝:开始意图

you need check this configuration and the file Manifest.xml

您需要检查这个配置和文件Manifest.xml

Good Luck

祝你好运

#8


1  

I solved this exception by changing the target sdk version from 19 onwards kitkat version AndroidManifest.xml.

我通过从kitkat版本的AndroidManifest.xml中修改目标sdk版本19来解决这个异常。

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

#9


0  

My problem was that I had this: Android:. lang。SecurityException:权限拒绝:开始意图 Instead of this: Android:. lang。SecurityException:权限拒绝:开始意图

我的问题是我有: