Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't understand isFinishing

Tags:

java

android

I've been studying Google IO 2012 code
In one of the activities (HomeActivity.java) they're doing as follows:

void onCreate(Bundle savedInstance)
{
   if(someCondition) {
      // start some other activity here
      finish(); // finish this activity
   }

   if(isFinishing()) return;

   // More code here
}

I wonder why they do not put return right after finish() but instead checking isFinishing() ?

like image 795
Alexander Kulyakhtin Avatar asked Oct 20 '12 18:10

Alexander Kulyakhtin


1 Answers

An Activity can be finished in a number of ways.

finishActivity from an activity that has called startActivityForResult

finishAffinity and finishFromChild

So isfinishing is used to account for such cases.

like image 126
nandeesh Avatar answered Sep 22 '22 19:09

nandeesh