android 12 onBackPressed

Viewed 231

Android 12 has changed behavior for back button. However, sometimes the behavior is confusing. For example, when I press it, my app does not go away (onResume is called right after onPause); other times, when I press it, my app goes away but a previously used app is opened. Other times, when I press it, my app goes away as expected (as with older versions of Android).

I've seen this behavior with other apps too. For example: the default "Files" app in Google Pixel 3a.

Is it a bug? or can I do something in my app to have always the expected behavior (as with older versions of Android)? Thanks a lot for your time.

1 Answers

Overriding onBackPressed in your launcher activity and calling finish in it would ensure your app always behaves as with older versions of Android.

Related