title: Up to parent activity - on Android
body: <p>After receiving a notification in my app, clicking on it opens activity B. Activity B has a parent activity A. Here is the manifest:</p>
  
  <pre><code>&lt;activity
      android:name="com.evapp.activities.B"
      android:label="@string/title_activity_B"
      android:parentActivityName="com.evapp.activities.A"
      android:screenOrientation="portrait" &gt;
  
      &lt;!-- Parent activity meta-data to support 4.0 and lower --&gt;
      &lt;meta-data
          android:name="android.support.PARENT_ACTIVITY"
          android:value="com.evapp.activities.A" /&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p>In activity B I have the up functionality enabled (left arrow near the activity action's bar icon), here is the code:   </p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      getActionBar().setDisplayHomeAsUpEnabled(true);
      ...
  </code></pre>
  
  <p>The problem is that if activity B was opened via clicking on the notification (activity A was not the one to bring activity B) the when clicking on the icon the app is closed. I would like to make it open it's parent activity, A. Is it possible? or should I do it with <code>startActivity()</code> from activity B?</p>
  
  <p><strong>Update 1-</strong> I have added this code:</p>
  
  <pre><code>@Override
  public boolean onOptionsItemSelected(MenuItem item) 
  {
     switch (item.getItemId()) 
     {
         case android.R.id.home:
              Intent upIntent = NavUtils.getParentActivityIntent(this);
              if (NavUtils.shouldUpRecreateTask(this, upIntent))
              {
                  TaskStackBuilder.create(this)
                      .addNextIntentWithParentStack(upIntent)
                      .startActivities();
              } 
              else 
              {
                  NavUtils.navigateUpTo(this, upIntent);
              }
  
              return true;
  </code></pre>
  
  <p>Thanks </p>