Reputation: 8392
I tried the answers from here, but I cannot get an activity to finish.
Here is the code:
private void myMethod() {
startActivity(startNewActivityOpen2);
GlobalVars.questionHolders = null; //is being called.
finish();
amTransitioning = true;
}
Calling Activity was started with these flags:
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
I tried
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK);
but this didn't work.
I can see that finish is getting called. My logcat is saying:
Duplicate finish request for ActivityRecord{426f37f8 u0 com.assistek.ediary/.PRO_GridOther t5569 f}
The activity continues along its merry way without finishing and I am getting a null pointer error because a singleton's value is getting cleared.
Upvotes: 0
Views: 281
Reputation: 20656
I guess you want amTransitioning
to be true
, so you have to call it before finishing the Activity
.
I can see that finish is getting called. My logcat is saying:
Are you finishing the Activity
in other method or something? If you do so that's the message on Logcat
. If you want to avoid this message, just before finishing add YOURACTIVITY.isFinishing()
if it's true don't finish, otherwise finish().
Upvotes: 0
Reputation: 595
finish(); does not terminate the activity the way you think it continue executing any code called after finish() you should write a "return;" after finish to avoid any code execution
Upvotes: 1