Extension to request IGNORE BATTERY OPTIMIZATIONS. Remember: this will not help to run your app in the background!

Hi guys,
I don’t know how relevant the above thread still is. I heard that it cannot run on OS above Oreo. I am using Oreo. NEWBIE ALERT: How do I implement the above request into kodular?

And what should I type in with activitystarter.action?
Is it:
“set activitystarter.action to android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS”

or

"set activitystarter.action to ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS"
(Like the link to the document given in the post)

And for the package name:
Thunkable’s format is " com.thunkable.android.yourName.appName" according to poster.
But kodular is “io.kodular.yourName.appName”?

And if the above is no longer relevant to solve the run in background issue. Can someone point me to a way to have my timer resume (After app stops running in background) with the CORRECT duration by using the system clock as a reference? I just can’t get it to work. And how do I get my timer to run at the same rate as the system clock? It seems to lag by 1 second, every 2 to 3 seconds of system clock.

4 Likes

what is ACTION_IGNORE BATTERY OPTIMIZATIONS/REQUEST_IGNORE_BATTERY_OPTIMIZATIONS is it a permission

I think, it is supposed to make your device think that the app does not need battery optimizations. So, your device will run in the background without getting killed even after your screen is off.

so should i ask for permission: get permission IGNORE_BATTERY_OPTIMIZATIONS

This will not make the app run in the background

1 Like

I realized you are right, when my app still resets itself after about an hour. Either that, or I did not do it right.

What do you suppose it do? And do you have any other solutions?

I think it does what it says…
IGNORE_BATTERY_OPTIMIZATION

Kodular Team has to do it

Correct me if I am wrong, but if IGNORE_BATTERY_OPTIMIZATIONS is the cause of apps shutting down in the background, then if the app ignores the optimization requests, it won’t get shut down, right?

The App can run but if closed from recent tabs thn the app will be stopped. Basically if you want to do anything in the background it should be done via a Service which is like an app but without the UI Part. Google can give better and clear answers about it

2 Likes

I see. Thank you.

1 Like

I can offer a small extension to set this, however, and this is why I did not publish it: Google will reject apps, which are trying to use that feature

Taifun

4 Likes

Taifun, may I have the extension please? I am using it for a personal app. And the app really depends on running in the background. I don’t have the knowledge, time or skills to use android studio either.
I really need my dynamic card views to not be reset when I minimize the app and the timer to keep running in the background. If you have it, I would truly appreciate you offering it. :laughing:

Also, I read that there is the “ask for the user’s permission” method too. Maybe you have an extension for that, so I can know immediately, if it can work with my phone, when the app asks me for permission to enable it?

Immposible for make running in back groud

sorry, but this will not work…
Kodular apps not really are able to run in the background

see also the notes here Settings  |  Android Developers

Note: most applications should not use this; there are many facilities provided by the platform for applications to operate correctly in the various power saving modes. This is only for unusual applications that need to deeply control their own execution, at the potential expense of the user’s battery life. Note that these applications greatly run the risk of showing to the user as high power consumers on their device.

Taifun

1 Like

I really don’t mind the battery drain, if the ignoring of battery optimizations can work. For the dynamic cards to not be reset (if the ignoring of battery optimizations don’t work), I am trying to store values of the dynamic cards to TinyDB, then load them using on app resume but it works strangely. Using local variables vs global variables have their own strange behavior. I will post it in a new topic.

But, if you have the extensions for ignoring battery optimizations, I would like to try it on my phone. I am using using oreo 8.0.0, which is supposed to work. Unless, I am misunderstanding the thunkable post.

By the way, I did read that link, but I understand none of it. I am not a programmer professionally, I only started with app inventor.

Global variables will reset when you relaunch the application too. Instead of storing the components in TinyDB, just save the content, and when user relaunches the app just create them again with a loop.

I am using global variables just for storing stuff to TinyDB. TinyDB is supposed to be permanent right? But it is behaving strangely. Please view my new post. Thank you.

Taifun, if you have the extension and it could work, I don’t mind buying you a cup of coffee for it. :grin:

you can download the extension and an example project here
batopt.aia (7.2 KB)
batopt.apk (2.9 MB)
com.puravidaapps.TaifunBatteryOptimization.aix (6.7 KB)

there is only one method
request
which opens the following dialog for the user
screenshot
Note: you have to build the app else this will not work!

Warning: Google Play might reject your app if you are using this extension!
see also Extension to request IGNORE BATTERY OPTIMIZATIONS. Remember: this will not help to run your app in the background!

Remember: Kodular apps are not really able to run in the background! Also not with this extension!

If you want to donate something, you can do it here: https://paypal.me/puravidaapps
thank you

Taifun

11 Likes

Thank you so much Taifun!! I will definitely donate if it works!!