Android Question Do these On-Boot Methods conflict with each other?

JohnC

Expert
Licensed User
Longtime User
I am working on a service that has a high importance that it runs when the device boots up.

But some users are reporting that it does not load on bootup.

I know the usual method to do this is to put this line in the service:
B4X:
#StartAtBoot: True

But I also know that there is probably some behind-the-scenes code that also runs as part of B4A so that the "Starter" service will actually start before my particular "Bootup" service will start. So, since I don't know exactly how that hidden code works, I just want to make sure what I am trying is not causing new issues.

So, in an attempt to increase the chances of the service being started when the device powers on, I added these lines to the manifest:
B4X:
AddReceiverText(Bootup,
<intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"/>
    <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
    <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
    <action android:name="android.intent.action.PRE_BOOT_COMPLETED"/>
    <action android:name="android.intent.action.TIME_SET"/>
    <action android:name="android.intent.action.DATE_CHANGED"/>
 
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>)

(some of the other intent filters are basically a plan B to get the service running if for some reason it doesn't receive the Boot_Completed intent)

So, is it ok for my service to have the #StartatBoot: True in it and those lines in the manifest?
 

JohnC

Expert
Licensed User
Longtime User
Does adding #StartAtBoot: True in a service do anything more (behind the scenes) other than simply add these lines to the manifest?

B4X:
AddReceiverText(Bootup,
<intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>)
 
Upvote 0
Top