Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 未经Y的许可,不允许启动service Intent X_Android_Service_Android Intent_Android C2dm - Fatal编程技术网

Android 未经Y的许可,不允许启动service Intent X

Android 未经Y的许可,不允许启动service Intent X,android,service,android-intent,android-c2dm,Android,Service,Android Intent,Android C2dm,意图在清单中具有适当的权限: 舱单: 04-25 14:16:30.931: E/AndroidRuntime(6638): FATAL EXCEPTION: main 04-25 14:16:30.931: E/AndroidRuntime(6638): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extra

意图在清单中具有适当的权限:

舱单:

04-25 14:16:30.931: E/AndroidRuntime(6638): FATAL EXCEPTION: main
04-25 14:16:30.931: E/AndroidRuntime(6638): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.exclusive26.igale/com.exclusive26.igale.Push_Activity}: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2553)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:2595)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.ActivityThread.access$2000(ActivityThread.java:121)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.os.Looper.loop(Looper.java:130)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.ActivityThread.main(ActivityThread.java:3701)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at java.lang.reflect.Method.invokeNative(Native Method)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at java.lang.reflect.Method.invoke(Method.java:507)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at dalvik.system.NativeStart.main(Native Method)
04-25 14:16:30.931: E/AndroidRuntime(6638): Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.ContextImpl.startService(ContextImpl.java:867)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.content.ContextWrapper.startService(ContextWrapper.java:336)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at com.google.android.c2dm.C2DMessaging.register(C2DMessaging.java:54)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at com.exclusive26.igale.Push_Activity.register(Push_Activity.java:124)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at com.exclusive26.igale.Push_Activity.onActivityResult(Push_Activity.java:58)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.Activity.dispatchActivityResult(Activity.java:3908)
04-25 14:16:30.931: E/AndroidRuntime(6638):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2549)
04-25 14:16:30.931: E/AndroidRuntime(6638):     ... 11 more

参数发送正确(Push_活动上下文和一些电子邮件地址可能我遗漏了什么,但错误显示为“com.google.android.c2dm.permission.RECEIVE”,清单包含“com.google.android.c2dm.permission.SEND”因此,我看不到完美的匹配。

代码是正确的。我创建了一个新项目,复制了代码,不再有任何问题了。

仅针对未来出现此错误的用户: 清单文件应如下所示:

public static void register(Context context,
        String senderId) {
    Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
    registrationIntent.setPackage(GSF_PACKAGE);
    registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    registrationIntent.putExtra(EXTRA_SENDER, senderId);
    context.startService(registrationIntent);
    // TODO: if intent not found, notification on need to have GSF
}

而不是

<permission
    android:name="YOUR_PACKAGE.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />


我花了大约5个小时来找出我的项目中的错误:)

如果我们在活动Java文件中错误地使用了某些资源的名称,也可以提供此错误。我也犯了同样的错误,但我还没有使用任何服务或权限。问题是onCreate()方法的资源id错误。

我只能在接收器中定义一个“android:permission”。也许您可以在开始时将其添加到总体权限部分?失败点是在触发以下行时(无法在context.startService中调试代码):context.startService(RegistrationContent);上下文是Push_活动。意图包含带有附加项的新意图:{act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf(有附加项)}第二个附加项是:intent.puttera(“sometxt”,pendingent.getBroadcast(上下文,0,new intent(),0));-所有这些都被发送到context.startService(intent);我已经用相同的代码创建了一个新项目,用于调试目的,它可以正常工作!我没有idia为什么我不能从我的原始项目开始使用phonegap和PushPlugin服务。有趣的是,插件自动设置清单,就像上面的第一个示例一样,我得到了指定的错误。像第二个例子一样修改它。如果可能有帮助,我有相同的行,但顺序不同。我的项目运行时,我订购如上所述
public static void register(Context context,
        String senderId) {
    Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
    registrationIntent.setPackage(GSF_PACKAGE);
    registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    registrationIntent.putExtra(EXTRA_SENDER, senderId);
    context.startService(registrationIntent);
    // TODO: if intent not found, notification on need to have GSF
}
<permission
    android:name="YOUR_PACKAGE.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
    android:name="YOUR_PACKAGE.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
<uses-permission android:name="YOUR_PACKAGE.permission.RECEIVE" />