title: How to resume activity instead of restart when going "up" from action bar
body: <p>I have <strong>two</strong> activities. Say <code>Activity A</code> and <code>Activity B</code>.
  <br/>
  From <code>Activity A</code> I click a button to launch <code>Activity B</code> This is the code I use for this:</p>
  
  <pre><code>Intent intent = new Intent(this, ActivityB.class);
  this.startActivity(intent);
  </code></pre>
  
  <p><hr/>
  Now at this point, I am in <code>Activity B</code>. On the on create method of <code>Activity B</code>, I enable the up button. </p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_view_news);
  
      getActionBar().setDisplayHomeAsUpEnabled(true); //Here//
  }
  </code></pre>
  
  <p>and on the event handle for the "up" button, i have this code:</p>
  
  <pre><code>public boolean onOptionsItemSelected(MenuItem item){
       switch (item.getItemId()) {
          case android.R.id.home:
              finish();
              NavUtils.navigateUpFromSameTask(this);
          default:
              return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p><hr/>
  Now I decide to go back to <code>Activity A</code> I click the up button in the action bar which looks like this: <img src="https://i.stack.imgur.com/qLkFf.png" alt="enter image description here"></p>
  
  <p>Now the problem is, when I click the "up button", it goes back to <code>Activity A</code> which is fine, but it <strong>restarts</strong> it. How can make it stop restarting? I just want it to <strong>resume</strong>.
  <br/><br/>
  When I use my hardware back button, it works as expected. i.e it goes to <code>Activity A</code> and resumes it instead of restarting it.
  <br/><br/>
  I want my activity to resume because on that activity, I download some string online and so I don't want it to keep re downloading the data when a users goes from <strong>Activity B -> Activity A</strong>
  <hr/>
  <strong>Edit</strong> My manifest file for <code>Activity B</code> section looks like this:</p>
  
  <pre><code>&lt;activity
      android:name="com.example.android.ActivityB"
      android:label="@string/title_activity_view_news"
      android:parentActivityName="com.example.android.ActivityA"&gt;
      &lt;meta-data
          android:name="android.support.PARENT_ACTIVITY"
          android:value="com.example.android.ActivityA" /&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p><hr/>
  <strong>Edit 2 [Answer]</strong>
  Ok so, this was pretty unexpected but in my AndroidManifest.xml, in the Activity A section, I had to add the following line liner. <code>android:launchMode="singleTop"</code> so it now looks like this:</p>
  
  <pre><code>&lt;activity
      android:name="com.example.android.ActivityA"
      android:label="@string/app_name" 
      android:launchMode="singleTop"&gt; //**HERE**//
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
  
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/14462456/returning-from-an-activity-using-navigateupfromsametask/16147110#16147110">The explanation to this is given here</a></p>