title: How to finish all child activities from parent in android
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6302640/how-to-close-all-child-activities-from-parent-in-android">How to close all child activities from parent in android</a>  </p>
  </blockquote>
  
  
  
  <p>I'm new to android. Actually one handler is running in Home Activity A for every 30 sec to check the net connection.</p>
  
  <p>If I'm  went to activity C by A->B->C, If there in no net connection at that time, then i want to close Activity B and C, then want to show message box in Activity A.     </p>
  
  <p>But My problem is My handler is running for every 30 sec in Home Activity A.      But If i was in Activity C or some other Activity how to find which activity is my Application currently focussed now. Then i want to finish those child activities and want to show Home Activity A I have some 9 child activities in Activity B. </p>
  
  <p>I heard about using "FLAG_ACTIVITY_CLEAR_TOP" . I used the code as follows in the handler in Home activity A itself. But got error. </p>
  
  <pre><code>        Intent intent = new Intent( ctx, Homepage.class );    
          intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | 
               Intent.FLAG_ACTIVITY_CLEAR_TOP); 
      ctx.startActivity( intent );
  </code></pre>
  
  <p>Here Homepage.class is my Home Activity A and i set that activity in manifest file as     </p>
  
  <pre><code>    android:launchMode="singleTop"    
  
  Please help me.
  </code></pre>