title: android preserve activity flow on startactivity
body: <p>I'm having following activity flow in normal case:</p>
  
  <p><a href="https://i.stack.imgur.com/WZeZn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WZeZn.png" alt="enter image description here"></a></p>
  
  <p>Activity B can be started by any activity. When B is started from any activity, on returning from B, it returns to the activity that started the activity B, whereas I want to preserve normal flow and go back to A instead of the activity that started it.</p>
  
  <p>Manifest has:</p>
  
  <pre><code>&lt;activity
      android:name=".Bactivity"
      android:label="@string/title_b"
      android:theme="@style/AppTheme"
      android:parentActivityName=".Aactivity" &gt;
      &lt;meta-data
          android:name="android.support.PARENT_ACTIVITY"
          android:value="com.mycompany.myfirstapp.Aactivity" /&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p>I start activity B from any other activity using:</p>
  
  <pre><code>Intent intent = new Intent(getApplicationContext(), Bactivity.class);
  
  intent.putExtra(SELECTED_CONTACT_ID, contact_id);
  intent.putExtra(SELECTED_CONTACT_NAME, contact_name);
  
  startActivityForResult(intent, 1);
  </code></pre>
  
  <p>Also, if started from a notification, I do:</p>
  
  <pre><code>Intent intent = new Intent(this, Aactivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
          PendingIntent.FLAG_ONE_SHOT);
  NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this).setContentIntent(pendingIntent).......;
  </code></pre>
  
  <p>How can I return from activity B to activity A even if B is started by any activity or notification?</p>