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

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:

Version 2 of the extension can now be found here App Inventor Extensions: Ignore Battery Optimization | Pura Vida Apps

there is method
request

which opens the following dialog for the user

dialog

Note: you have to build the app else this will not work!

Version 2 offers additionally method
isIgnoring
to check, if app is ignoring Battery Optimization.

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! - #11 by Taifun

If you want to donate something, you can do it here: PayPal.Me
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…

3 Likes

Bummer. But what can we say. I don’t think it is ever going to happen, unfortunately.

Correct, that will not happen in the near future or as you said

2 Likes

Luckily, we have hundreds of options outside Kodular/App Inventor. You see, it’s the same as if I want to make a very complex game (I like working with canvas, sprites, animation, etc.) Kodular can handle most of the things you need for a fairly decent game, but don’t expect to make a first person shooter in it! If you reach to that point, then it’s time to migrate to a new platform like Unity, Unreal, etc.

Same with your need for background services. You know it exists right?, Then all you need to do is go and learn the platform that allows that.

3 Likes

Totally understand your point. But currently, App Inventor is what I have the time to tinker with. It is relatively easy, tries to make things easy for non-professional or even hobbyist coders and doesn’t take much time learning its “language”.

5 Likes

That’s exactly why you don’t have some of the very professional features in it, like background services. Because in order to make it easy for non professionals, its architecture had to be made in a way some things got “sacrificed” to make the more important and used ones possible.
I also wish some day it will happen, but I made peace with the fact that it’s just another thing (of the many) I can’t do with Kodular/App Inventor.

5 Likes

I know I said this before, but I may try to make App Inventor over again using newer technologies and I’ll work on it as a hobby.

4 Likes

Now, that’s something I truly am looking forward to!