This is a MIUI bug that affects any apps that displays Notifications. Specifically apps that want their notification to direct their users to a specific screen and then want to control the screen the user sees after they push the Android back button.
This issue happens if the “Display pop-up windows while running in the background” (older MIUI versions this is called “Start in background”) permission is "Deny"(default) for the app. This seems like a bug (unintended side effect) on this permission but regardless it is a background behavior app developers should be aware of and is something that should be callout on this site.
App developer creates a Notification with a
PendingIntent that will open "ActivityA" and puts "ActivityB" on the back stack via the
TaskStackBuilder API. The back stack is defined in their
android:parentActivityName and the
meta-data tag with
The bug here is if the user swipes away the app and taps on a notification. After the user presses the device's back button the app goes to the homescreen instead of following the app developer's intended back stack, which was "ActivityB". This bug does not happen on other Android devices so this is a MIUI issue. It isn't an Android AOSP issue.
I have created a simple example project that demonstrates this issue:
I have also report this bug on the official "Xiaomi Community" bug:
|Issue Title||Created Date||Updated Date|