Android Question Really confused about OnBoot Receiver

FrostCodes

Active Member
Licensed User
Hello everyone, my app has a service that is started at boot before without receivers and this was fine till the new requirements. I read this post and I can see I can still run my code at boot but the issue I have is I think its better to run my code from a service so at first, I was thinking better I create a receiver for the OnBoot and then call my service but then I read I can't do this as the app is in the background and then I thought maybe I should move my whole code to the receiver.

The problem now is that my code runs at certain times of the day and downloads a new update of some databases with or without the user opening the app as it's essential the user access the latest database data automatically. The update can take from 1 to 15 mins or even more depending on the user's internet connection speed which means before this was fine as I show a notification to keep the update running in a service till it's done.

In receivers, I can see that android expects what you do to be short and it kills the receiver so I am really confused about how to solve my issue.
Please any advice?
 

FrostCodes

Active Member
Licensed User
You are correct @Computersmith64. I forgot that the on boot intent is in the exemptions list.
This means that the regular #StartAtBoot: True in a service will work.

I can say that from my experience there are many devices that do not honor this list. There are several discussions in the forum where users got the ForegroundServiceStartNotAllowedException although they were sending high priority messages which is an allowed use case.
Ok Erel thanks, I guess it's just better to split the task as you advised initially to avoid weird issues from such devices or do you have a newer view on the previous advice ?
 
Upvote 0
Top