简体   繁体   中英

Kivy crashes on resume after screen lock

I'm writing my first app with Kivy and am using Buildozer to deploy the app to Android. Although my app resumes when I switch between applications, if ever I lock my screen, the app does not resume at all.

Is there anything that I'm missing? The documentation seems to refer to this problem as a "bug" from previous versions. I'm using Kivy 1.10.0.

Here is what I did to handle pause/resume:

class MyApp(App):
    def build(self):
        return sm
    def on_pause(self):
        return True
    def on_resume(self):
        return sm

You implemented the on_resume method wrong. Try this -

def on_resume(self):
  # Check if any data needs replacing, usually none 
  pass

I had this exact same issue and I have been pulling my hair out for about a week. After digging through the logs and changing my search terms, I found this issue: https://github.com/kivy/python-for-android/issues/462

Raising the minimum Android API in buildozer.spec fixed the issue immediately! I changed mine from android.minapi = 9 to android.minapi = 15 but you can experiment and find the right one for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM