katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1k forks source link

Background service does not work in SDK 31, app crashes #573

Closed rcasunshare closed 1 year ago

rcasunshare commented 1 year ago

When going to the background, the application stops working on devices with Android 12

Exception java.lang.RuntimeException: at android.app.ActivityThread.handleCreateService (ActivityThread.java:4953) at android.app.ActivityThread.access$1800 (ActivityThread.java:310) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2300) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:226) at android.os.Looper.loop (Looper.java:313) at android.app.ActivityThread.main (ActivityThread.java:8663) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:567) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135) Caused by java.lang.IllegalArgumentException: at android.app.PendingIntent.checkFlags (PendingIntent.java:382) at android.app.PendingIntent.getActivityAsUser (PendingIntent.java:465) at android.app.PendingIntent.getActivity (PendingIntent.java:451) at android.app.PendingIntent.getActivity (PendingIntent.java:415) at de.appplant.cordova.plugin.background.ForegroundService.makeNotification (ForegroundService.java:241) at de.appplant.cordova.plugin.background.ForegroundService.makeNotification (ForegroundService.java:160) at de.appplant.cordova.plugin.background.ForegroundService.keepAwake (ForegroundService.java:129) at de.appplant.cordova.plugin.background.ForegroundService.onCreate (ForegroundService.java:97) at android.app.ActivityThread.handleCreateService (ActivityThread.java:4940)

woodely commented 1 year ago

Same issue.

rcasunshare commented 1 year ago

Same issue.

Solution:

https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background/commits/e11ee4f4324cb1f67db093d2c7a815ea23bc48bb