Bug? Problems compiling to device in standby mode

corwin42

Expert
Licensed User
Longtime User
When I compile an app with a starter service to a device (which is connected via USB, should be the same with wifi connection) and the device is in standby or the lockscreen is visible I get the following error:

B4X:
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.amberhome.weather2/de.amberhome.weather2.main}: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=de.amberhome.weather2/.starter }: app is in background uid UidRecord{c69dc33 u0a340 RCVR idle change:uncached procs:1 seq(0,0,0)}
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2928)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3063)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:198)
    at android.app.ActivityThread.main(ActivityThread.java:6729)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=de.amberhome.weather2/.starter }: app is in background uid UidRecord{c69dc33 u0a340 RCVR idle change:uncached procs:1 seq(0,0,0)}
    at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1589)
    at android.app.ContextImpl.startService(ContextImpl.java:1544)
    at android.content.ContextWrapper.startService(ContextWrapper.java:664)
    at anywheresoftware.b4a.keywords.Common.StartService(Common.java:894)
    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.startFromActivity(ServiceHelper.java:184)
    at de.amberhome.weather2.main.onCreate(main.java:64)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
    ... 11 more

The device is a Nokia 7+ with Android 9.

If the device is unlocked everything works fine.

I guess the problem is that the activity starts in the background (because of the lockscreen) and then the starter service can't be initialized.
 
Top