I'm building an Android app that handles incoming events.
When I receive 1 such event, if my app is in the foreground, I immediately generate an AlertDialog that requires the user's attention.
However, when the app is in the background, the user does not see this, even though the AlertDialog has already been generated. If I manually go back to my app, I see the AlertDialog and I'm able to click OK or cancel.
I tried generating a notification dialog that appears when my app is in the background. This works, and I put the PendingIntent as MainActivity. When I tap on the notification, it brings me back to my app. However, the AlertDialog isn't there anymore.
Comparing the logcats of tapping on the notification vs manually going back to my app, I notice several differences.
When I manually go back to my app, I see MainActivity is resumed immediately. However, when I tap on the notification, it first goes back to the constructor of the class that generated the notification, a few other classes/fragments, before finally resuming MainActivity.
Does anyone know why this might be the case?
Thanks.