I am sorry but could not find proper information on how to use the StartAtBoot.... I need that the app besides any custom laucher on the android gets started and running when booted
My Starter module is based on the standard created by b4a
B4X:
#Region Service Attributes
#StartAtBoot: True
#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.
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
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
What I need to do in order to make the MAIN module to start running?
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
CallSubDelayed2(Main, "Activity_Create", True)
End Sub
Not sure if this is valid, but did not work either
On android 11.1 boxes seems things does not startup
Sub Service_Start (StartingIntent As Intent)
' Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
LogColor("yTEF Service started !", Colors.Red)
StartActivity(Main)
End Sub
and it works partially, the application freeze and does no display the screen
I have implemented this, not sure is right and the best option but it is working on the most problematic android 11.1 box i have here:
B4X:
Sub Service_Start (StartingIntent As Intent)
' Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
LogColor("yTEF Service started !", Colors.Red)
If Not(Started) Then
Started = True
CallSubDelayed(Me, "StartMain")
End If
End Sub
Sub StartMain
StartActivity(Main)
End Sub