I have just started insuring my apps work with Android 12. What I notice is that for (I believe) all of them when the back button is pressed, then onPause() is called, but not onDestroy(). This means the app is still running.
Previously, onDestroy() was called after onPause() when the back button was pressed.
It is a definite problem for ones running a background service that has (actually, must have) a notification. Stopping the service is typically done in onDestroy() and certainly not in onPause(). Since onDestroy() is not called, the service continues running and the notification remains up. If you select the notification, it brings up the [running] app again. There is no way to stop the service and hence the notification, except by killing the process via the overview (left) button.
I also notice that if an app with a service crashes, then the notification stays up. This is surely not desired behavior.
You can, and apparently have to, kill the process with the overiew (left) soft button).
I can get around this by implementing onBackPressed:
@Override public void onBackPressed() { // This seems to be necessary with Android 12 // Otherwise onDestroy is not called Log.d(TAG, this.getClass().getSimpleName() + ": onBackPressed"); finish(); super.onBackPressed(); }
but that seems like a kludge.
For other apps maybe it doesn't matter they are still running or not. However, it is unexpected behavior.
Added later: This is apparently intentional and is a change from previous behavior. It is mentioned in this article (curtesy of @ianhanniballake):
https://developer.android.com/about/versions/12/behavior-changes-all#back-press
I have several apps, and I have verified it is happening with all of them on Android 12. It is causing problems with those that have services.
The implied question for this issue is what to do about it. I personally am implementing onBackPressed for those and leaving the others be.