When my app goes to background and i receive a broadcast that my app is in inconsistent state and i want to ensure that the next time my app comes to foreground, i launch the Launcher(or root) activity. To do this I have the following approaches,
All my activities derive from a base . When resuming check for the state of app in base. Launch Root activity if the state is inconsistent. Problem : App resume should be fast and checking state is a db call. Also there would be a visible flip to Root activity which i want to avoid.
Catch hold of foreground activity in broadcast receiver, clear the task and launch main activity. Problem: I have to maintain a reference to top activity like described here.
- Kill the process in broadcast receiver when inconsistent state is reached.
What is the best approach?