One of the challenges that developers of any non-small Android app need to deal with, is the multiple possible entry points.
Updated tutorial is available here: https://www.b4x.com/android/forum/threads/starter-service-consistent-entry-point.57599/
During development in almost all cases the app will start from the Main activity.
I'm sure that many programs start with code similar to:
Everything seems to work fine during development. However the app "strangely" crashes from time to time on the end user device.
The reason for these crashes is that the OS can start the process from a different activity or service. For example if you use StartServiceAt and the OS kills the process while it is in the background.
Now the SQL object and the other resources will not be initialized.
The next version of B4A will include a new (optional) feature that will make it much simpler to manage this issue.
The process will always start from the Starter service. The Starter service will be created and only then the activity or service that were supposed to be started will start.
This means that the Starter service is the best place to initialize all the application-wide resources.
Other modules can safely access these resources.
This is an optional feature. You can safely remove the Starter service and you can also add this service to existing projects.
Updated tutorial is available here: https://www.b4x.com/android/forum/threads/starter-service-consistent-entry-point.57599/
During development in almost all cases the app will start from the Main activity.
I'm sure that many programs start with code similar to:
B4X:
Sub Activity_Create (FirstTime As Boolean)
If FirstTime Then
SQL.Initialize(...)
SomeBitmap = LoadBitmap(...)
'additional code that loads application-wide resources
End If
End Sub
The reason for these crashes is that the OS can start the process from a different activity or service. For example if you use StartServiceAt and the OS kills the process while it is in the background.
Now the SQL object and the other resources will not be initialized.
The next version of B4A will include a new (optional) feature that will make it much simpler to manage this issue.
The process will always start from the Starter service. The Starter service will be created and only then the activity or service that were supposed to be started will start.
This means that the Starter service is the best place to initialize all the application-wide resources.
Other modules can safely access these resources.
This is an optional feature. You can safely remove the Starter service and you can also add this service to existing projects.
Last edited: