Google revised how long an app can ‘work’ continuously since Android 8. It is not possible to keep alive an app in background or otherwise for a long time (. eg your one or two days).
A few months ago there was a discussion about long term use of a plugged in Android and discussed all the reasons why apps cannot run for long term; essentially because of ‘safeguards’ in the Android system libraries. Sorry, I cannot find it. Perhaps one of the other moderators can.
Your issue is your app/android device shuts down because the Android operating system tells it to. Any way to defeat that is a hack. Keep the device charger plugged in, use a StayAwake routine, limit the battery protections, or run your app on your PC using a games type emulator like BlueStacks (not a nice solution) etc may be the best that is possible
Most of my apps published on the Play Store run all night and they (music) still run in the morning without problems, as many users told me when they forgot to activate the timer. 12 hours and more, isn't that a long period of time?
No. Not when some developers want their apps to run 24/7, the devices not plugged in etc. Did you read the link that explains? And they do not want to use a hack... and a hack is what is required to subvert Google policy.
How about if you temporarily make a black background visible on the screen when the device switches to idle (sleep) mode, so that when the device wakes up, only this black screen is visible (and thus for the user it is not recognizable that the device has been woken up).
when the wakephone switches on the phone i see this
sorry I didn't catch what you mean
in the wakeup phase my phone switches on (and you see that locked screen) and after some seconds (after exchanging data with the server) it goes off.
Instead of lighting up the screen, It would be nice if i could add a notification (like the one in the picture) with some data about what is happening.
I'm now going to test again the TaifunOptimization.Request (just one instance) and will let you know.
Yes, of course, most people use a lock screen. It was just a (rash) brainstorm of mine ...
since I also tried everything (to no avail) to keep the ExoPlayer running in standby in Kodular.
I made some tests, not so easy to do because the phone wakes up by itself for other reasons, in the condition that my app was in foreground before switching of the display.
The Doze delay, like in the Figure 1, is increasing always in the same way: firing my timer (instead of every minute) after 2 minutes, then after about 3minutes, then after about 5minutes, then even more and stopping also the internet connection. Sometimes the delay starts again from 2minutes probably depending on what is happening from other apps.
This means that for the goal of Doze to save the battery, my users need to keep the phone always switched on, consuming much more battery than with screen off without Doze or they must bring with them a battery pack to simulate the charging condition
I didn't find much difference not using TaifunOptimization.Request, or using it in the beginning or every 1sec or 500ms.
Using LaunchMyApp.WakePhone keeps internet connection alive but doesn't allow my timer to be fired with intervals different from 2-7 minutes.
Going to the battery settings page for my app and setting NO RESTRICTION also doesn't change the delay of Doze.
Really looks like the only solution is to keep the phone always switched on, but this is really crazy. Also I don't think this is a limit of App Inventor.
What do you suggest?
I'm working on the issue.
I have some good news you could also test on your apps.
I found that if I activate one or more timers with different interval from 10sec to 500ms, all of them with TimerAlwaysFires=true, the App running with the screen Off, the timer that was firing every 2, 3, 5, 7 minutes instead of 1min, now fires almost every minute.
No wakeup, no taifun restrinction for battery.
Maybe your Timer 500ms was helping for other reasons.
Ops, the manual setting no restriction for battery is set. I will test again without special settings and will let you know.
i can confirm that the "no restriction for power saving" settings or TaifunOptimization.Request are important too.
Now i will start to test what happens when the app is in background
I don't know exactly why, but everything is working now, like when i have the charger connected, both in foreground and background mode. It's like waking up after a nightmare, i was on the point of renouncing to this project.
To summarize: i had to remove all the stuff and workarounds, just leave the TaifunOptimization.Request or the android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
and after i put TimerAlwaysFires on each clock i had, the app works normally, like it should.
I think some clock, without timeralwaysfires was not completing something when in doze...
As usual i end my stupid posts with "sorry for disturbing".