B4X:
Dim J As HttpJob
J.Initialize("J",Me)
J.PostString(url , data )
Wait For (j) JobDone(j As HttpJob)
Log(phpFile & ": j.GetString=" & j.GetString)
My app works fine in foreground; if I put it in the background by tapping Home button, after 3 successful httpjob calls, the app crashed with following error messages during the 4th httpjob call.
Could someone kindly give me som hint on how to fix the error, please?
TIA
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **
Service started in the background. Trying to start again in foreground mode.
java.lang.RuntimeException: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.deedeegroup.quisila/.httputils2service
at anywheresoftware.b4a.keywords.Common$12.run(Common.java:1215)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.deedeegroup.quisila/.httputils2service
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelable(Parcel.java:3346)
at android.os.Parcel.createExceptionOrNull(Parcel.java:2433)
at android.os.Parcel.createException(Parcel.java:2422)
at android.os.Parcel.readException(Parcel.java:2405)
at android.os.Parcel.readException(Parcel.java:2347)
at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:6968)
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1927)
at android.app.ContextImpl.startForegroundService(ContextImpl.java:1893)
at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:798)
at anywheresoftware.b4a.keywords.Common.StartServiceImpl(Common.java:924)
at anywheresoftware.b4a.keywords.Common.StartService(Common.java:911)
at anywheresoftware.b4a.keywords.Common$12.run(Common.java:1183)
... 8 more
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:771)
at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:679)
at com.android.server.am.ActivityManagerService.startService(ActivityManagerService.java:14102)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2960)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3036)