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

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!!


Well, it literally asked whether to “let app always run in background”. The extension works! But the phone must either be lying (because my app still gets RESET to its original state [All dynamic card views GONE!], after several hours of screen off) Or App running in background can still get RESET now and then. Because I have verified with my other device, that if the app screen is up front, it won’t get RESET.

1 Like

The extension does not “work.” Kodular apps do not run in the background as said in many topics including this one.

Yes. I guess, I still need to give it a try and Taifun still deserves his coffee regardless :+1:
If the phone allows the app to run in background, then it must be kodular that refuses to allow that. Ignoring the allowing of apps to run in background, so to speak.

EDIT: Before this, it was my understanding that Kodular Apps are not suggested to run in background because it drains battery. But it would like to give that as an option. And there’s no way for kodular apps to run in background, even if it wanted to. Now, I realize, it actually doesn’t want to have its apps run in the background or it doesn’t have ability to utilize the “run in background” feature by Android.

4 Likes

it was my wish for 2018 to support in kodular but no update so far

1 Like

Has been like this from the very beginning. App inventor tried to give the run in background feature some years ago using services (http://services.appinventor.mit.edu). But the website now says that it is shutting it down. Bummer…