Reputation: 5676
Similar to Activity's isFinishing() API for use in onPause(), is there a good mechanism to determine whether the activity is being created when in onResume()?
Upvotes: 0
Views: 103
Reputation: 10363
You can create a boolean value, initially false and you onResume should look something like this:
if (!flag)
{
// Activity is created for the first time
flag = true;
}
else
{
// Activity was created before
}
Upvotes: 0
Reputation: 9599
You could have a boolean variable that saves the state of "isStarting".
boolean isStarting;
In your onCreate method, you'd set it to true:
isStarting = true;
So in you onResume() method you can check if the activity is starting:
if(isStarting == true) {
// Activity has been created!
//set the variable to false
isStarting = false;
}
else {
// Nope...
}
I hope this helps!
Upvotes: 1