問題描述
我開始使用 Kivy for Android 開發一個應用,今天成功地構建和運行了一個 APK.
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.
推薦答案
我沒用過Kivy,也沒開發過android,但是我找到了:
I have never used Kivy or developed for android, but I was able to find:
這個
來自鏈接:
如果您只是希望您的應用程序不完全關閉(這樣它就不會每次都以啟動畫面等方式完全重新啟動),您只需向您的 App 類添加一個 on_pause 方法,它應該會返回真的.您還可以在此方法中執行任何暫停前的操作.但是,應用程序并沒有真正保持運行,它只是保持內存狀態.
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.
如果您希望它在后臺進行計算,您可以使用 Python-for-android.
If you want it to do computations in the background you can use Python-for-android.
這篇關于在 Kivy 中處理 Android 上的應用程序暫停/恢復的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!