runnerup
runnerup copied to clipboard
[Bug] Exit the App with Android "back" Button
Having the App open and pressing the Android back Button/functionality doesn't work on my Android 13 decice. A toast message appears "Press Back again to exit" pressing the Back-Button one time.. After that only this toast message appears again and again continuing to press back.
Device: Google Pixel Android Version: 13
Back must be pressed within 3s, otherwise there is a new toast.
Exiting the app with triggering the back button multiple times within 3 seconds doesn't work for me. I get the toast that I have to trigger it again though.
In general the back button works in other parts of the app
I have the same problem with my Pixel 6 running Android 14. From Android 13 the onBackPressed
method (that this app uses to exit) is deprecated and should not be used. See https://developer.android.com/reference/android/app/Activity#onBackPressed(). Perhaps this causes the problem?
That seem to explain it. My OnePlus with Android 13 phone should get the Android 14 update within two months, hopefully deviating less than A13 so I can investigate better.
I have made some tests and using androidx.activity.OnBackPressedCallback (and OnBackInvokedCallback in SettingsActivity) seems to fix the issue. I can make a PR I you want to have a look/try.
I have made some tests and using androidx.activity.OnBackPressedCallback (and OnBackInvokedCallback in SettingsActivity) seems to fix the issue. I can make a PR I you want to have a look/try.
yes please
Unfortunately, using OnBackPressedCallback/OnBackInvokedCallback did not solve the issue after all.
During my tests, I had enabled the Predictive back animations feature on my device (Settings > System > Developer options). When this setting is disabled, the problem is still there.
A quick and simple fix, perhaps, would be to replace
super.onBackPressed(); // finish activity
with
finish(); // finish activity
in SettingsActivity.onBackPressed() (line 416)?
The root cause seems to be TabActivity that MainLayout extends. If StartActivity is declared as the main activity (in Manifest.xml) instead of MainLayout, exiting from StartActivity works as intended.
I think the "correct" fix would be to replace TabActivity with AppCompatActivity as suggested in #648.
Thanks for the info. It often is more difficult then it seems.
I think the "correct" fix would be to replace TabActivity with AppCompatActivity as suggested in #648.
Yes, that requires rewriting the activities to fragments so not trivial (maybe for settings too, that should be easier though).
This seems to be handled in #1176