Handling app suspend/resume on Android in Kivy

浪子不回头ぞ 提交于 2020-07-08 13:37:45

问题


I started developing an app with Kivy for Android and managed to build and run an APK today.

Couldn't find a straight answer on how to handle my app being suspended and resumed by a user without going through the initialization/loading screen? Is there a special mechanism that will handle this?

It is rather annoying that every time I send the app to the background and bring focus back to it there is that loading screen popping up.


回答1:


I have never used Kivy or developed for android, but I was able to find:

This

From the link:

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.

If you want it to do computations in the background you can use Python-for-android.




回答2:


Kivy has an on_pause and on_resume methods that you can use to handle these events. These are methods of the main App class that are called automatically for you.



来源:https://stackoverflow.com/questions/21547353/handling-app-suspend-resume-on-android-in-kivy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!