权限拒绝:getIntentSender()
我试图在应用程序小部件提供程序的 onUpdate 方法中为小部件设置待处理意图,但是在尝试设置待处理意图时,我不断收到 Permission Denial: getIntentSender() 消息。为了简单起见,我已经剥离了该类:
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
Intent appIntent = new Intent(context,Main.class);
PendingIntent pendingAppIntent = PendingIntent.getActivity(
context, 0, appIntent, 0);
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
为此,我得到了以下堆栈跟踪:
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): java.lang.RuntimeException: Unable to start receiver com.distilledmedia.thejournal.widget.JournalAppWidgetProvider: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=6536, uid=10062, (need uid=-1) is not allowed to send as package com.distilledmedia.thejournal.client
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1805)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.access$2400(ActivityThread.java:117)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Handler.dispatchMessage(Handler.java:99)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Looper.loop(Looper.java:130)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at java.lang.reflect.Method.invokeNative(Native Method)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at java.lang.reflect.Method.invoke(Method.java:507)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at dalvik.system.NativeStart.main(Native Method)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): Caused by: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=6536, uid=10062, (need uid=-1) is not allowed to send as package com.distilledmedia.thejournal.client
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Parcel.readException(Parcel.java:1322)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Parcel.readException(Parcel.java:1276)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityManagerProxy.getIntentSender(ActivityManagerNative.java:2254)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.PendingIntent.getActivity(PendingIntent.java:195)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at com.distilledmedia.thejournal.widget.JournalAppWidgetProvider.onUpdate(JournalAppWidgetProvider.java:41)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.appwidget.AppWidgetProvider.onReceive(AppWidgetProvider.java:61)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
这是清单中应用程序小部件的条目:
<receiver android:name="com.distilledmedia.thejournal.widget.JournalAppWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/journal_widget" />
</receiver>
以及主要活动的条目:
<activity android:name="com.distilledmedia.thejournal.client.Main"
android:label="@string/app_name"
android:configChanges="orientation" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
这是否与以下事实有关 :小部件与主要活动位于不同的包中?
非常感谢任何帮助
I'm trying to set a pending intent for a widget in the onUpdate method of the app widget provider however I'm constantly getting a Permission Denial: getIntentSender() when trying to set the pending intent. I've stripped the class right down for simplicity:
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
Intent appIntent = new Intent(context,Main.class);
PendingIntent pendingAppIntent = PendingIntent.getActivity(
context, 0, appIntent, 0);
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
I get the following stacktrace for this:
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): java.lang.RuntimeException: Unable to start receiver com.distilledmedia.thejournal.widget.JournalAppWidgetProvider: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=6536, uid=10062, (need uid=-1) is not allowed to send as package com.distilledmedia.thejournal.client
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1805)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.access$2400(ActivityThread.java:117)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Handler.dispatchMessage(Handler.java:99)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Looper.loop(Looper.java:130)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at java.lang.reflect.Method.invokeNative(Native Method)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at java.lang.reflect.Method.invoke(Method.java:507)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at dalvik.system.NativeStart.main(Native Method)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): Caused by: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=6536, uid=10062, (need uid=-1) is not allowed to send as package com.distilledmedia.thejournal.client
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Parcel.readException(Parcel.java:1322)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.os.Parcel.readException(Parcel.java:1276)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityManagerProxy.getIntentSender(ActivityManagerNative.java:2254)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.PendingIntent.getActivity(PendingIntent.java:195)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at com.distilledmedia.thejournal.widget.JournalAppWidgetProvider.onUpdate(JournalAppWidgetProvider.java:41)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.appwidget.AppWidgetProvider.onReceive(AppWidgetProvider.java:61)
06-23 10:18:45.270: ERROR/AndroidRuntime(6536): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
And here's the entry for the App Widget in the manifest:
<receiver android:name="com.distilledmedia.thejournal.widget.JournalAppWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/journal_widget" />
</receiver>
And the entry for the main activity:
<activity android:name="com.distilledmedia.thejournal.client.Main"
android:label="@string/app_name"
android:configChanges="orientation" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Could it be to do with the the fact that the widget is in a different package to the main activity?
Any help much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您的答案是这个回答蜗牛。
I think your answer is this answered by snailer.