Why App is not able to receive GCM Notification in Android O? - android

I am using the GCM inside my Application. But in Android O App stops receiving notification if it goes into background. I am using StartService for Lower API 26 and StartForgroundService for upper API 26 Android devices. Also tried JobSchedular and JobIntentService but still App is getting crashed with the below error.
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.teacout.devzspoon cmp=com.teacout.devzspoon/com.devzspoon.services.MyGcmListenerService (has extras) }: app is in background uid UidRecord{cf40c05 u0a582 RCVR bg:+2m52s193ms idle change:uncached procs:1 proclist:22992, seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1600)
at android.app.ContextImpl.startService(ContextImpl.java:1546)
at android.content.ContextWrapper.startService(ContextWrapper.java:669)
at android.content.ContextWrapper.startService(ContextWrapper.java:669)
at android.support.v4.content.WakefulBroadcastReceiver.startWakefulService(WakefulBroadcastReceiver.java:99)
at com.google.android.gms.gcm.GcmReceiver.zzf(Unknown Source:23)
at com.google.android.gms.gcm.GcmReceiver.zze(Unknown Source:0)
at com.google.android.gms.gcm.GcmReceiver.onReceive(Unknown Source:106)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3406)
at android.app.ActivityThread.-wrap18(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1807) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:7000) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) 
06-05 17:30:40.508 22992-22992/com.teacout.devzspoon E/UncaughtException: java.lang.RuntimeException: Unable to start receiver com.google.android.gms.gcm.GcmReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.teacout.devzspoon cmp=com.teacout.devzspoon/com.devzspoon.services.MyGcmListenerService (has extras) }: app is in background uid UidRecord{cf40c05 u0a582 RCVR bg:+2m52s193ms idle change:uncached procs:1 proclist:22992, seq(0,0,0)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3413)
at android.app.ActivityThread.-wrap18(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1807)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

Related

Permission Denial : Starting Intent ( lock task mode / kiosk mode )

Any one have a suggestion how to solve this error ?
I am trying to run lock task with intent getLaunchIntentForPackage but I have no idea why this error is coming and which type of permission it wants to run this task.
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.example.videoplayer cmp=com.example.videoplayer/.MainActivity } from ProcessRecord{fd194a9 7523:com.example.lock/u0a190} (pid=7523, uid=10190) with lockTaskMode=true
at android.os.Parcel.createExceptionOrNull(Parcel.java:2425)
at android.os.Parcel.createException(Parcel.java:2409)
at android.os.Parcel.readException(Parcel.java:2392)
at android.os.Parcel.readException(Parcel.java:2334)
at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2326)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1758)
at android.app.Activity.startActivityForResult(Activity.java:5407)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
at android.app.Activity.startActivity(Activity.java:5747)
at com.example.lock.MainActivity.launchApp(MainActivity.kt:110)
at com.example.lock.MainActivity.onCreate$lambda-0(MainActivity.kt:62)
at com.example.lock.MainActivity.$r8$lambda$yGvyKllS4GN5cYzDCcbSf8EdXb0(Unknown Source:0)
at com.example.lock.MainActivity$$ExternalSyntheticLambda0.onClick(Unknown Source:2)
at android.view.View.performClick(View.java:7455)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1194)
at android.view.View.performClickInternal(View.java:7432)
at android.view.View.access$3700(View.java:835)
at android.view.View$PerformClick.run(View.java:28810)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.wm.SafeActivityOptions.checkPermissions(SafeActivityOptions.java:283)
at com.android.server.wm.SafeActivityOptions.getOptions(SafeActivityOptions.java:155)
at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1006)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:670)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1223)
I'm currently running into the same error. The only thing I can hand to you is that it can be solved by using the DevicePolicyManager.setLockTaskPackages as stated on the android site: https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode#allowlist_apps

How correct share of files android 11

I try to share of files in android 11,but i get an exception:
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.DOWNLOAD_COMPLETE flg=0x10 pkg=ru.alexanderkozlovskiy.test (has extras) } in ru.alexanderkozlovskiy.test.ActivityMain$loadReciever$1#bbd5a77
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1572)
at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:7861)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Caused by: java.lang.SecurityException: UID 10415 does not have permission to content://downloads/all_downloads/1199 [user 0] [prefix]
You can see my code on https://github.com/AlexandrKozlovskiy/share_issue. Thanks everybody for any help.

Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdInternalReceiver android Oreo

Hello I am using GCM for push notification, i am getting lot of crashes on Android O
WakefulBroadcastReceiver.java line 99
android.support.v4.content.WakefulBroadcastReceiver.startWakefulService
I am not using FCM for push notification, kindly help me out to fix this issue in Android O. Following is the stacktrace of the error in fabric.
Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdInternalReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.firebase.INSTANCE_ID_EVENT pkg=com.tapmad.tapmadtv cmp=com.tapmad.tapmadtv/com.google.firebase.iid.FirebaseInstanceIdService (has extras) }: app is in background uid UidRecord{b7ea475 u0a216 RCVR bg:+1m30s74ms idle procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3399)
at android.app.ActivityThread.-wrap18(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1780)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

How can i On GPS Automatically without asking User?

I've tried this code but It's not working Properly.
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent, Manifest.permission.WRITE_SECURE_SETTINGS);
Getting this Error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.setting/com.setting.activity.TraceLocationActivity}:
java.lang.SecurityException: Permission Denial: not allowed to send
broadcast android.location.GPS_ENABLED_CHANGE from pid=28258,
uid=10395
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Caused by: java.lang.SecurityException: Permission Denial: not allowed to send
broadcast android.location.GPS_ENABLED_CHANGE from pid=28258,
uid=10395
at android.os.Parcel.readException(Parcel.java:1665)
at android.os.Parcel.readException(Parcel.java:1618)
at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3533)
at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1012)
at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:426)
at com.setting.activity.TraceLocationActivity.onCreate(TraceLocationActivity.java:46)
at android.app.Activity.performCreate(Activity.java:6915)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:156) 
at android.app.ActivityThread.main(ActivityThread.java:6523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
How can i On GPS Automatically without asking User?
This is not possible, for obvious privacy and security reasons.

Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdInternalReceiver

My app integrates FCM to receive push notifications and it works okay. However, I am facing issue that on installation it crashes randomly. It is very random and occurring on OS 6.0+ devices till latest but randomly occurs.
Code wise, in service class only show notification code is written and added service in manifest.
I am getting below exception on app loads
Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdInternalReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.firebase.INSTANCE_ID_EVENT pkg=com.xx.xx cmp=com.xx.xx/com.google.firebase.iid.FirebaseInstanceIdService (has extras) }: app is in background uid UidRecord{997e286 u0a92 RCVR idle procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
at android.app.ActivityThread.-wrap17(Unknown Source)
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:6540)
at java.lang.reflect.Method.invoke(Method.java)
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.firebase.INSTANCE_ID_EVENT pkg=com.xx.xx cmp=com.xx.xx/com.google.firebase.iid.FirebaseInstanceIdService (has extras) }: app is in background uid UidRecord{997e286 u0a92 RCVR idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1497)
at android.app.ContextImpl.startService(ContextImpl.java:1453)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at android.support.v4.content.WakefulBroadcastReceiver.startWakefulService(WakefulBroadcastReceiver.java:91)
at com.google.firebase.iid.FirebaseInstanceIdInternalReceiver.zzh(Unknown Source:12)
at com.google.firebase.iid.FirebaseInstanceIdInternalReceiver.zzb(Unknown Source:76)
at com.google.firebase.iid.FirebaseInstanceIdInternalReceiver.onReceive(Unknown Source:28)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
at android.app.ActivityThread.-wrap17(Unknown Source)
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:6540)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Use this library version for firebase
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'

Categories

Resources