Open jkasten2 opened 2 years ago
@petrnalevka @Artaud I think this notification backstack issue would be good to document on the https://dontkillmyapp.com/xiaomi page. If you agree but don't have to bandwidth to make the changes let me know and I can submit a PR.
@rl885 @petrnalevka @Artaud Happy write this content and throw up a PR, but before doing so would like to know if dontkillmyapp.com is still being updated and if the PR would likely be accepted by the maintainers.
Summary
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.
Details
App developer creates a Notification with a
PendingIntent
that will open "ActivityA" and puts "ActivityB" on the back stack via theTaskStackBuilder
API. The back stack is defined in theirAndroidManifest.xml
withandroid:parentActivityName
and themeta-data
tag withname="android.support.PARENT_ACTIVITY"
.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.
Minimum Reproducible Example
I have created a simple example project that demonstrates this issue: https://github.com/OneSignal/NotificationActivityBackstackExample
References
I have also report this bug on the official "Xiaomi Community" bug: https://c.mi.com/thread-4045696-1-0.html