Android Question Auto start b4A app on boot

bdunkleysmith

Active Member
Licensed User
Longtime User
I have an app (cable TV remote control with big buttons for my elderly father) which I want to start and be visible on boot of the Android (version 7.0) tablet on which I'm running it. It consists of a Main module and Starter service.

I have read both of these posts: Autostart app and Auto starting your app, but it is still unclear to me what I need to include in either Main or Starter, or indeed in another service. I have tried various things, but none result in the app launching on boot and in some cases I receive a message "The Starter service should never be started from a receiver."

Any guidance on the specifics of what I need to do in my existing module/service or if necessary an additional one would be appreciated. Besides modifying my code, is anything required regarding permissions on the Android tablet itself?

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
but it is still unclear to me what I need to include in either Main or Starter, or indeed in another service
Do not use the Starter service for this. Use any other Service and set the startatboot attribute here.
is anything required regarding permissions on the Android tablet itself?
no
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
Thanks DonManfred, but where you say
Do not use the Starter service for this.
do you mean that I should move code which is currently in the Starter service into say the Main module so I don't have a Starter service in the project at all?

Then where you say
Use any other Service and set the startatboot attribute here.
does that mean I need to create a new service? If so and say I call it Autoboot, apart from
B4X:
#Region  Service Attributes
    #StartAtBoot: True
#End Region
what else needs to be in the newly created Autoboot service?

A shell of an example project would be great to explain this and I'm sure others would benefit too.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
do you mean
no. I meant not to use the startatboot flag on the Starter-Service. Use any other service for the startatboot-feature.

Android will start the service at boot. As the starter service is started with your process you dont need to start the starter service manually.
what else needs to be in the newly created Autoboot service?
Maybe opening an Activity which you want to open. I suggest not to open any activity. Just let the services do service jobs. It may bother the enduser.

If you only want your app running you should consider doing a Kiosk app.
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
Thank you DonManfred - I was not aware of the kiosk app concept, but after reading Device Owner / TaskLock / Kiosk apps 2017, it sounds like the mode I want. My app will be the only one to run on the tablet and the kiosk mode looks like having the benefit of avoiding the user accidentally exiting the app and getting into places they shouldn't.

I think my project may have already been auto-starting after I added a new "Autoboot" activity with #StartAtBoot: True, however it was hidden because of the tablet's lock screen and sleep settings, but the kiosk app approach looks the way to go.

Thanks for your guidance - I'll update this thread once I've implemented that mode.
 
Upvote 0
Top