-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
android/activity: Add Application.ActivityLifecycleCallbacks helpers #2669
Conversation
Code looks super good and promising, but not tested yet during runtime, meanwhile can you please rebase so we can see a green run from the CI? |
Do you want me to exercise it in the test app? |
Uh, that would be super nice, but not mandatory. The rebase was just to include a recent change that will allow the unit tests to run. |
It's fine. I already had something more or less there but I'd punted to work on something else. |
Well, I'm glad I did because now I found out that it doesn't work on API 31. Trying to figure out why... |
The `Application.ActivityLifecycleCallbacks` interface is used to register a class that can receive callbacks on Activity lifecycle changes. Add a `PythonJavaClass` implementing the interface and helper functions to register python callbacks with it. This can be used to perform actions in the python app when the activity changes lifecycle states.
ab010d5
to
8483275
Compare
I rebased and added some callbacks in the test app. It works fine for both sdl2 and webview on API 29 and API 30, but I can't figure out why it doesn't work on API 31. It seems like an Android bug that the callbacks are never sent. |
False alarm. It does work fine on API 31. It just seems they changed the activity lifecycle a bit. Before the activity would be stopped by going to the overview. Now you have to go into a different activity or back to the home screen to go through the pause/stop cycle. Then it will go back through the start/resume cycle when going back to the app. So, I think this works fine on all the API levels I tried - 29, 30 and 31. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thank you for the tests and well-written docs!
Tested both sdl2
and webview
APK on API 31, and worked flawlessly!
…ivy#2669) The `Application.ActivityLifecycleCallbacks` interface is used to register a class that can receive callbacks on Activity lifecycle changes. Add a `PythonJavaClass` implementing the interface and helper functions to register python callbacks with it. This can be used to perform actions in the python app when the activity changes lifecycle states. (cherry picked from commit b379a1c)
…ivy#2669) The `Application.ActivityLifecycleCallbacks` interface is used to register a class that can receive callbacks on Activity lifecycle changes. Add a `PythonJavaClass` implementing the interface and helper functions to register python callbacks with it. This can be used to perform actions in the python app when the activity changes lifecycle states.
The
Application.ActivityLifecycleCallbacks
interface is used to register a class that can receive callbacks on Activity lifecycle changes. Add aPythonJavaClass
implementing the interface and helper functions to register python callbacks with it. This can be used to perform actions in the python app when the activity changes lifecycle states.