I am trying to build android app using kivy. How I can hide my app but still keep it running in the background like a deamon?
from kivy.config import Config
Config.set('graphics', 'fullscreen', 'fake')
from kivy.app import App
from kivy.uix.button import Button
class MyApp(App):
def build(self):
button = Button(text="Exit", size_hint=(None, None))
button.bind(on_press=exit)
return button
if __name__ == '__main__':
MyApp().run()
In Windows, apps can continue to perform actions even when you are not actively in the app's window. These are commonly called background apps. You can decide which apps will run in the background, and which won't.
How Background Apps Affect Your Android Battery. Your Android device can run multiple apps in the background for a few reasons. Most of the time, it won't cause any battery or memory consumption problems. One factor causing your Android device's battery to drain too quickly is when there are too many apps running.
You need to use an android service if you want to actually do computation in the background. Python-for-android can do this, the relevant documentation is here (old_toolchain). For the new toolchain method see here.
If you just want your app to not be closed completely (so that it doesn't restart entirely with the splash screen etc. every time), you just have to add an on_pause
method to your App class, and it should return True
. You can also do any pre-pause stuff in this method. However, the app doesn't really keep running, it just keeps memory state.
In the latter case, be aware that android can and sometimes will kill apps in a pause state. This is a normal part of the way apps are handled and you can't avoid it, so you should save any important state in your on_pause
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With