Android Question [SOLVED] Start application when the phone is switched on

rscheel

Well-Known Member
Licensed User
Longtime User
I need to open an application that I am developing when the phone is turned on, there is some method to do it.

Thank you.
 

Star-Dust

Expert
Licensed User
Longtime User
#StartAtBoot: True
in a service
It is correct and then the service starts the Activity
B4X:
Sub Service_Start (StartingIntent As Intent)
    StartActivity(Main)
End Sub


Even though I think starting an App when I start the device is not always a good idea.
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
Thank you very much, very grateful for your help.

For those who visit and come to this thread what he enhanced in the way of follows, taking account of the comments.

B4X:
#Region  Service Attributes
    #StartAtBoot: True
   
#End Region

Sub Process_Globals
    Dim wakelock As PhoneWakeState
    Dim tm As Timer
End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
    wakelock.PartialLock
    ToastMessageShow("Servicio Iniciado", True)
    tm.Initialize("tm",10000)
    tm.Enabled = True
End Sub

Sub Service_Destroy

End Sub

Sub tm_tick
    tm.Enabled = False
    wakelock.ReleasePartialLock
    StartActivity(Main)
End Sub
 
Upvote 0
Top