I'm having a slightly odd problem, and I can't seem to find anyone with the same problem when googling although this may be because I'm not explaining it well.
In my app the user logs in, as soon as they hit log in a loading activity opens, after this the main page activity opens.
Now if the app is on the loading activity and the user presses the 'Home' button on their phone or goes to a different app my activity will still continue loading the information in the background.
As soon as loading is finished then the main page activity is launched, regardless of whether the app is still being used. This main page will then open on top of whatever the user was doing.
I am using an async task for the loading, with the following onPostExecute() method:
@Override
public void onPostExecute() {
//open the main page
Intent mainPage = new Intent(getApplicationContext(), MainPageActivity.class);
mainPage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mainPage.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK );
startActivity(mainPage);
}
What would be the best way to stop this behaviour?
I want the main page activity to be ready to open/already opened next time the user brings the app to the foreground I don't want it to open on top of what they are doing.
Thanks for your time