I keep getting this error.
I am not sure if it is CloudKVS or HTTP causing this issue.
Some of my code...
Starter
Common
Main (on exiting)
B4X:
*** Service (starter) Create ***
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
WakeLock already held.
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.ConnectException: Failed to connect to /192.168.1.92:51042, Response:
Error sending task: java.net.ConnectException: Failed to connect to /192.168.1.92:51042
** Activity (main) Pause, UserClosed = true **
No wakelock.
ResponseError. Reason: java.net.ConnectException: Failed to connect to /192.168.1.92:51042, Response:
Error sending task: java.net.ConnectException: Failed to connect to /192.168.1.92:51042
ResponseError. Reason: java.net.ConnectException: Failed to connect to /192.168.1.92:51042, Response:
Error sending task: java.net.ConnectException: Failed to connect to /192.168.1.92:51042
** Service (httputils2service) Destroy **
** Service (starter) Destroy (ignored)**
java.lang.RuntimeException: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=golfcard.sapphire/.httputils2service }: app is in background uid UidRecord{a4f34f2 u0a727 CEM bg:+1m16s820ms idle procs:1 seq(0,0,0)}
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1167)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=golfcard.sapphire/.httputils2service }: app is in background uid UidRecord{a4f34f2 u0a727 CEM bg:+1m16s820ms idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1538)
at android.app.ContextImpl.startService(ContextImpl.java:1484)
at android.content.ContextWrapper.startService(ContextWrapper.java:663)
at anywheresoftware.b4a.keywords.Common.StartService(Common.java:894)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1137)
... 7 more
I am not sure if it is CloudKVS or HTTP causing this issue.
Some of my code...
Starter
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
Common.mySQL.Initialize(Common.DBDirectory, "card.db", True)
Common.ckvs.Initialize(Me, "ckvs", Common.ServerUrl)
Common.ckvs.SetAutoRefresh(Array(Common.User), 1)
End Sub
Sub Service_Start (StartingIntent As Intent)
Sleep(10000)
Service.StopAutomaticForeground
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
Common
B4X:
Dim const ServerUrl As String = "http://192.168.1.92:51042"
Dim ckvs As ClientKVS
Dim User As String = "u1"
Dim mySQL As SQL
Main (on exiting)
B4X:
Common.wakelock.ReleaseKeepAlive
Activity.Finish