在 Kivy 中处理 Android 上的应用程序暂停/恢复

Handling app suspend/resume on Android in Kivy(在 Kivy 中处理 Android 上的应用程序暂停/恢复)
本文介绍了在 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 上的应用程序暂停/恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
cocos2d-android: how to display score(cocos2d-android:如何显示分数)
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
Android file copy(安卓文件拷贝)
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)