Android Question "#StartAtBoot: true" will not start at boot any more with the 1-Dec-2020 Android 10 update

rleiman

Well-Known Member
Licensed User
I noticed that starting from the 1-Dec-2020 Android 10 update, service modules that have "#StartAtBoot: true" will not start at boot any more. This was working on my phone when the 1-Nov-2020 Android 10 update was installed. People now are starting to complain my apps are not starting up when they have to restart their phones.

Here's is what used to happen with the 1-Nov-2020 update:
Upon restarting the phone, they screen would go through its boot sequence and I could eventually hear audio coming from my background running app. When I log into the phone, the app icon on the home screen would have that small red notification badge showing.

Here's is what is happening with the 1-Dec-2020 update:
Upon restarting the phone, they screen would go through its boot sequence and I would never hear audio coming from my app because the service module will now not start running. When I log into the phone, a message "Phone is starting" is displayed before the home screen is shown and the app will not have the small red notification badge showing. This is causing anyone with this version of Android to start giving my app low ratings on Google.

Has anyone figured out a work-around to the changes Google made?

Thanks in advance.
 

rleiman

Well-Known Member
Licensed User
1. You should check the logs while the phone is booting.
2. On some devices there is an option to "fast boot". Apps will not start in this mode.

Why do you need to start at boot?
It needs to start at boot because the app plays audio files at scheduled times. I noticed that Android reboots the phone every now and then and that stops the app from playing the audio at the scheduled time unless the user opens and closes the app.

The logs don't show any errors so I think it's something Google changed in the latest update.

The logs only show that phone is connected and nothing else. All of the boot sequence stuff in the logs only show up after the "Phone is starting" message is displayed after I log into the phone and into an app. Only after that point, that app keeps running until another time I reboot the phone. Even the Alexa app on the phone doesn't start up until after the "Phone is starting" is displayed and I open and close it.

Our phones are all Samsung. I found out Samsung phones don't have a fast boot option.It looks like there was a big change Google made between those two updates.

We have 4 Samsung phones for testing and have the Nov update on our S9, so I will try updating to the Dec one and see if the issue is only related to S10 phones.

Here is log after rebooting the S10 phone (I commented out the full ID number):
B4X:
Logger connected to: R38...........
--------- beginning of main
--------- beginning of system

After the "Phone is starting" message is displayed and only if I open and exit an app, this is what the log shows:
B4X:
Logger connected to: R38..........
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
At Starter.
** Activity (main) Create, isFirst = true **
Panel size is unknown. Layout may not be loaded correctly.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (servicemodule) Create ***
** Service (servicemodule) Start **
At service module.
** Activity (main) Pause event (activity is not paused). **
** Receiver (servicemodule) OnReceive **
** Service (servicemodule) Start **
At service module.
** Service (servicewidget) Destroy **
** Service (starter) Destroy (ignored)**

I have 2 log statements in the app to show when the starter and service module starts running.

And after starting and exiting one of the apps, the orange/red badge shows a number 1 for the service module running. As you can see not even my Alexa app or any other app on the phone home screen is running with the badges except for the one called Nature's Song which I opened and exited.

Interesting enough is that the messages texting app made by Google is the only app I have on the home screen that survives the reboot because they already made a work-around so their apps aren't affected. 😖

Photos of the phone booting up and after opening and closing the Nature's Song B4A app:
20210104_112224.jpg20210104_112357.jpg20210104_114309.jpg
 
Upvote 0

agraham

Expert
Licensed User
Even the Alexa app on the phone doesn't start up until after the "Phone is starting" is displayed and I open and close it.
I don't think it is only Samsung. I have several Android 10 and 11 phones and have noticed this 'new' message after rebooting them, but I haven't taken much notice of which phones as I didn't recognize that it introduces a significant behavior change.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Here's an update:

I updated our S9 phone to the Dec Android 10 update and rebooted it. All of our B4A apps loaded right up and had the badges. My conclusion is that the issue is on S10 or S10plus phones introduced by Google because the S9 never shows the "Phone is starting" message after I log in to the phone. Only our S10 shows that message and doesn't load up the apps.

I do hope someone has a work-around for the S10 and newer phones. I also noticed other people on the forum are also having issues with apps not working on the S10 and newer phones with the latest Android update.

Here is the coding that only works on the S9 phone flawlessly. If you know how to change the coding so it works with both the S9 and also the S10 and newer phones, please let me know.

In a service module.:
#Region  Service Attributes
    #StartAtBoot: true  
#End Region

Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
    lock.PartialLock
End Sub

Sub Service_Start (StartingIntent As Intent)

    Log("At service module.")

    Service.StartForeground(nid, CreateNotification("Tapping this notification will open the app."))
    StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)

    InitializeWhatsNeeded
End Sub

Sub CreateNotification (Body As String) As Notification

    Dim notification As Notification

    notification.Initialize2(notification.IMPORTANCE_LOW)
    notification.Icon = "icon"
    notification.SetInfo("Now running in the background.", Body, Main)

    Return notification
End Sub
 
Last edited:
Upvote 0

Sandman

Well-Known Member
Licensed User
A small anecdote, in case it gives a clue:

My app also starts in background, and while I don't have a modern Samsung to test it on, I do have a Pixel 2 with Android 11. My app always starts after a reboot, but it can take quite some time before doing so. It's easy to understand why: The phones had so many installed apps with StartAtBoot enabled that the phone got unresponsive after a boot as loads and loads of apps launches in the background. Horrible user experience. So Google added delays to spread them out over time and make the user happier - makes perfect sense.

So, bottom line: Perhaps test a reboot and check after 15 minutes or so if it's started? (And don't expect it to be started right away.)
 
Upvote 0

rleiman

Well-Known Member
Licensed User
We only have that trouble with our S10 plus phone. On reboot, the logs that phone only show that the phone is connected and that's all we see until I log into the phone and wait until the "Phone is starting" message is cleared. All of our phones have the same Android 10 update. Everything with the apps including the restarting of the apps work on our S7, S8 and S9. None of those phones forces that "Phone is starting" message. I wish I could somehow disable that and be able to tell all of our customers who have S10 phone how to disable it so their apps will restart when their phones restart.

I did try Ere's location sample and it did restart only after "Phone is starting" message was cleared. Since all of our development is B4APages apps, I will convert that sample to a B4APages app and see if it exhibits the same no restart issue on our S10.

Has anyone tried this one their S10 plus phone? This way we will know if we need to include special documentation of S10 customers. As a reminder, this issue is not restricted to B4A. It happens to all of the installed apps except for the Google apps. I hope someone is using a work-around.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
I converted the app to B4XPages and just like the original when run on our S10 plus will not restart until after the "Phone is starting" message was cleared. I'm including a link to the entire app project so anyone who has a S10 or S10 plus with the Android 10 dec update can see how the phone refuses to restart the app until the "Phone is starting" message was cleared. It works only on our other phones.

B4XPages Location app

Update: This issue is with the new Samsung version of the Android 10 security update for the S10. When I removed the need to log in to the phone, all the apps started to restart before I displayed the phone home screen.

I doubt any of our customers will want to do that. :( If you know of a work around, please let me know.
 
Upvote 0
Top