python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

on_stop never get's called when closing Android app.

Open abstractdonut opened this issue 5 years ago • 2 comments

Checklist

  • [X] the issue is indeed a bug and not a support request
  • [X] issue doesn't already exist: https://github.com/kivy/python-for-android/issues
  • [X] I have a short, runnable example that reproduces the issue
from kivy.app import App
from kivy.uix.label import Label

class StopApp(App):
    
    def on_stop(self):
        print("APP STOP APP STOP APP STOP")
        print("APP STOP APP STOP APP STOP")
        print("APP STOP APP STOP APP STOP")
    
    def build(self):
        return Label(text='Hello world')


if __name__ == '__main__':
    StopApp().run()
--dist_name=stop
--private .
--package=com.example.stop
--name "Stop"
--bootstrap=sdl2
--requirements=python3,kivy==master,android,sdl2
--arch=armeabi-v7a
--sdk_dir /home/user/android/
--ndk_dir /home/user/android/android-ndk-r19c/
--android_api 28
--ndk-api 21
--version 0.0.1
--debug
  • [X] I reproduced the problem with the latest development version (p4a.branch = develop)
  • [X] I used the grave accent (aka backticks) to format code or logs when appropriated

Versions

  • Python: 3.8
  • OS: Android
  • Kivy: 2.0.0rc3
  • Cython: 0.29.13
  • OpenJDK:

Description

I encountered this problem with an app that I'm developing which works as expected on Ubuntu 18 and Windows, but which fails on Android. The failure causes settings to not persist between successive runs due to on_stop not being called as expected.

I wrote the small example above to isolate the problem.

Expectation:

APP STOP APP STOP APP STOP
APP STOP APP STOP APP STOP
APP STOP APP STOP APP STOP

should appear in the shell or in logcat.

What happens: When launching the program from android_studio the expected string never appears in Logcat.

buildozer was not used, only p4a.

abstractdonut avatar Jul 29 '20 20:07 abstractdonut

on my app I was trying to use on_setop to save the user setting and on_start to read the setting when start the app but it;s not working on android, but if use on_pause() and on_resume() instead my app works well

ghost avatar Aug 21 '20 05:08 ghost

I also found that pressing the '<' (back arrow) on Android UI, the 'on_stop()" method is called correctly. What is not working is closing the app through the 'application list'.

mzakharocsc avatar Aug 21 '20 14:08 mzakharocsc