Hello,
I have a doubt about life cycle in Android 8+ and B4A 8.3... see:
- Suppose that I have a Http call in a service like the code as follows:
I have many questions:
- The StopAutomaticForeground will detect that service has finished and stop it BEFORE the http call back?
- If YES, the service will be restarted automatically and the callback will occur? BUT if the service was destroyed, when started the _Create will run again (If yes, we could have a problem with a double call here no?)
- And finally, considering all these questions, what is the correct way to rewrite a code like this to be compatible with all the versions of Android, including 8?
Please help! I'm really confused with the consequences of the Android 8+ behavior and callback routines in services...
I have a doubt about life cycle in Android 8+ and B4A 8.3... see:
- Suppose that I have a Http call in a service like the code as follows:
B4X:
Sub Service_Create
Dim Job As HttpJob
Job.Initialize("test",Me)
Job.Download("http://test.com")
End Sub
Sub Service_Start (StartingIntent As Intent)
Sleep(0)
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
Log("ok")
Else
Log("fail")
End If
Job.Release
End Sub
I have many questions:
- The StopAutomaticForeground will detect that service has finished and stop it BEFORE the http call back?
- If YES, the service will be restarted automatically and the callback will occur? BUT if the service was destroyed, when started the _Create will run again (If yes, we could have a problem with a double call here no?)
- And finally, considering all these questions, what is the correct way to rewrite a code like this to be compatible with all the versions of Android, including 8?
Please help! I'm really confused with the consequences of the Android 8+ behavior and callback routines in services...