在 Kivy 中处理 Android 上的应用程序暂停/恢复 [英] Handling app suspend/resume on Android in Kivy

查看:25
本文介绍了在 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 上的应用程序暂停/恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆