Friday, April 13, 2012

Calling finish() on an Android activity doesn't actually finish

You should put a return statement after that finish, because the method that called finish will be executed completely otherwise.
 
The method that called finish() will run to completion. The finish() operation will not even begin until you return control to Android.

suppose you have a method xyz like below

xyz()
{
statment1
statement2
.
.
finish();
statement6
statement7
}

Then the finish() function will be called after statement7 is executed and the control has returned to android.

So , if you want your app to finish() immediately then put a return statement after finish(), Like below
xyz()
{
statment1
statement2
.
.
finish();
return;
statement6
statement7

}

Statement6 and statement7 will not be executed any more

No comments:

Post a Comment