Handling app suspend/resume on Android in Kivy(在 Kivy 中处理 Android 上的应用程序暂停/恢复)
问题描述
我开始使用 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 上的应用程序暂停/恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Kivy 中处理 Android 上的应用程序暂停/恢复
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
