Run the application in background

后端 未结 2 604
余生分开走
余生分开走 2020-12-16 21:07

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
         


        
相关标签:
2条回答
  • 2020-12-16 21:23

    As Inclement already mentioned, you need to start an android service for this. This kivy planet post (which appeared after you asked the question) gives a walk through of how to have a program, a service, and have them interact with each other.

    0 讨论(0)
  • 2020-12-16 21:33

    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.

    0 讨论(0)
提交回复
热议问题