Android Question Autostart on android boxes with 11.x does not work

EduardoElias

Well-Known Member
Licensed User
Longtime User
I have a standalone app used to control some hardware and i use android boxes for that

on some android boxes i use a play store app that launches my app after boot and work fine

on some others i have added the home property on the manifest and it helped for that

however new android boxes with android 11. does not work for autostart neither use home property

is there another way to make the app start?
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
What exactly are you doing? Setting #StartAtBoot: True on a service (not starter service) and calling StartActivity?
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?
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
B4X:
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
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I have tried this:

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)

    StartActivity(Main)   
End Sub

and it works partially, the application freeze and does no display the screen
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
What exactly are you doing? Setting #StartAtBoot: True on a service (not starter service) and calling StartActivity?

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
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…