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

查看:70
本文介绍了在Kivy中处理Android上的应用暂停/恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用Kivy开发适用于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天全站免登陆