Android Question Start at boot, blank screen afterwards

MolsonB

Member
Licensed User
Longtime User
I have a program that monitors the charge/battery (if plugged in or not) and will start a shutdown timer when the power is removed. Used for in car system that will turn on and off with the car.

The service starts at boot in the background and everything works. When I click on the app for the first time after the tablet starts, it doesn't load Main. I just get a blank screen. If I back out of the app and re-open, Main loads.

In the Starter tab, line 130 is where I was trying to load Main when the app is opened for the first time. I think it's a work around, I'm trying to understand the flow of the system as a whole and wondering why Main doesn't load. What I've done to stop it from loading.

Log
** Service (starter) Create **
** Service (starter) Start **
^during boot
** Service (starter) Start **
^opening app for the first time
 

Attachments

  • Shutdown.zip
    67.8 KB · Views: 217

DonManfred

Expert
Licensed User
Longtime User
Dont use startatboot in the starter service!
Use another service. Set THIS service to start at boot.
 
Upvote 0

MolsonB

Member
Licensed User
Longtime User
Ok I created another service called "Boot" and set that option to StartAtBoot. It has nothing in it, other then a toastmessage to let the user know the service started in the background. I thought I had to call the 'Starter' service aswell, but it opens automatically. Well according to the logs, it starts even before the boot service.

It works though, when I open the app for the first time after startup, it loads Main. Thank you Don!

--------- beginning of system
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Service (boot) Create **
** Service (boot) Start **



B4X:
#Region  Service Attributes
    #StartAtBoot: 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

End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.Action = "android.intent.action.BOOT_COMPLETED" Then
        ToastMessageShow("Auto Shutdown service started", False)
    End If
'    StartService(Starter)
End Sub

Sub Service_Destroy

End Sub
 
Upvote 0
Top