GcmBroadcastReceiver IllegalStateException:不允许启动服务意图 [英] GcmBroadcastReceiver IllegalStateException: Not allowed to start service Intent
问题描述
GcmBroadcastReceiver IllegalStateException:不允许启动服务。
我正在处理Android中的FCM推送通知,意图
我在这个论坛中搜索了很多问题,但仍然没有得到解决它的帮助。
清单:
< uses-permission android:name =android.permission.INTERNET/>
< uses-permission android:name =android.permission.ACCESS_NETWORK_STATE/>
<使用权限android:name =android.permission.WAKE_LOCK/>
< uses-permission android:name =android.permission.VIBRATE/>
< uses-permission android:name =android.permission.RECEIVE_BOOT_COMPLETED/>
<使用权限android:name =android.permission.GET_ACCOUNTS/>
< uses-permission android:name =com.google.android.c2dm.permission.RECEIVE/>
< receiver android:name =com.parse.GcmBroadcastReceiver
android:permission =com.google.android.c2dm.permission.SEND>
< intent-filter>
< category android:name =com.kolbeh/>
< / intent-filter>
< / receiver>
< meta-data android:name =com.parse.push.gcm_sender_id
android:value =id:85490 ######/>
< service android:name =com.parse.PushService/>
< receiver
android:name =dinewhere.fcm.CustomPushReceiver
android:exported =false>
< intent-filter>
< action android:name =com.parse.push.intent.RECEIVE/>
< / intent-filter>
< / receiver>
错误记录:
10-16 16:52:19.621 25906-25906 / com.kolbeh E / AndroidRuntime:致命例外:main
过程:com.kolbeh,PID:25906
java.lang。 RuntimeException:无法启动接收器com.parse.GcmBroadcastReceiver:java.lang.IllegalStateException:不允许启动服务Intent {act = com.google.android.c2dm.intent.RECEIVE flg = 0x1000010 pkg = com.kolbeh cmp = com。 kolbeh / com.parse.PushService(有额外)}:应用程序在后台uid UidRecord {2ac0a5c u0a888 RCVR空闲过程:1 seq(0,0,0)} $ b $在android.app.ActivityThread.handleReceiver(ActivityThread .java:3259)
at android.app.ActivityThread.-wrap17(Unknown Source:0)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1677)
在android.os.Handler.dispatchMessage(Handler.java:105)
在android.os.Looper.loop(Looper .java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android .internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
导致:java.lang .IllegalStateException:不允许启动服务Intent {act = co m.google.android.c2dm.intent.RECEIVE flg = 0x1000010 pkg = com.kolbeh cmp = com.kolbeh / com.parse.PushService(has extras)}:app在后台uid UidRecord {2ac0a5c u0a888 RCVR idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1505)
at android.app.ContextImpl.startService(ContextImpl.java:1461)
在android.content.ContextWrapper.startService(ContextWrapper.java:644)
在android.content.ContextWrapper.startService(ContextWrapper.java:644)
在com.parse.ServiceUtils.runIntentInService(ServiceUtils。 java:37)
at com.parse.ServiceUtils.runWakefulIntentIn Service(ServiceUtils.java:68)
at com.parse.GcmBroadcastReceiver.onReceive(GcmBroadcastReceiver.java:21)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
在Android.app.ActivityThread.-wrap17(未知源:0)
at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler .java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
在java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal。 os.ZygoteInit.main(ZygoteInit.java:767)
您正在运行Android 8.0+,其中 切换到 切换到 targetSdkVersion
为26+。 您无法可靠地调用 startService()
来自后台,例如来自GCM接收器。相反,您应该:
startForegroundService()
和使用前台服务,或者
JobIntentService
在您的特定情况下,调用 startService()
的代码似乎来自Parse。您应该看看是否有更新的Parse客户端需要考虑Android 8.0。
I am working on FCM Push notification in Android, where I am getting this exception:
GcmBroadcastReceiver IllegalStateException: Not allowed to start service Intent
I have searched many question in this forum, but still didn't got help for solving it. My Log and Manifest patch is also given below.
Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.kolbeh" />
</intent-filter>
</receiver>
<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:85490######" />
<service android:name="com.parse.PushService" />
<receiver
android:name="dinewhere.fcm.CustomPushReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.OPEN" />
<action android:name="com.parse.push.intent.DELETE" />
</intent-filter>
</receiver>
Error Log:
10-16 16:52:19.621 25906-25906/com.kolbeh E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kolbeh, PID: 25906
java.lang.RuntimeException: Unable to start receiver com.parse.GcmBroadcastReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.kolbeh cmp=com.kolbeh/com.parse.PushService (has extras) }: app is in background uid UidRecord{2ac0a5c u0a888 RCVR idle procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
at android.app.ActivityThread.-wrap17(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.kolbeh cmp=com.kolbeh/com.parse.PushService (has extras) }: app is in background uid UidRecord{2ac0a5c u0a888 RCVR idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1505)
at android.app.ContextImpl.startService(ContextImpl.java:1461)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at com.parse.ServiceUtils.runIntentInService(ServiceUtils.java:37)
at com.parse.ServiceUtils.runWakefulIntentInService(ServiceUtils.java:68)
at com.parse.GcmBroadcastReceiver.onReceive(GcmBroadcastReceiver.java:21)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
at android.app.ActivityThread.-wrap17(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
You are running on Android 8.0+, with a targetSdkVersion
of 26+. You cannot reliably call startService()
from the background, such as from a GCM receiver. Instead, you should either:
Switch to
startForegroundService()
and use a foreground service, orSwitch to
JobIntentService
In your particular case, the code that is calling startService()
appears to be from Parse. You should see if there is an update to the Parse client that takes Android 8.0 into account.
这篇关于GcmBroadcastReceiver IllegalStateException:不允许启动服务意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!