2 MainActivities after Broadcast receiver
<p>My app should be opened after the broadcast receiver operation. But if my app opens at the current moment I need to delete the previous MainActivity and create a new MainActivity. How to start MainActivity from broadcast receiver and delete the previous MainActivity if the activity starts before?  </p>

<p>Broadcast:</p>

<pre><code>Intent initialIntent = context.getPackageManager().getLaunchIntentForPackage("com.cc.dd");
    initialIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    initialIntent.putExtra(Constants.NUMBER,getIncomingNumber(mCallState));
    context.startActivity(initialIntent);
</code></pre>

<p>I tried to use flags but I  have strange logs:</p>

<blockquote>
  <p>D/CallReceiver: main: [RINGING]<br>
  D/CallReceiver: main: [Incoming call true]<br>
  D/MainActivity: main: [ON_PAUSE]<br>
  D/MainActivity: main: [ON_CREATE]<br>
  D/MainActivity: main: [ON_START]<br>
  D/MainActivity: main: [ON_RESUME]       </p>
</blockquote>

<p>I see the  MainActivity previous version goes to onPause and  the  new version starts. Why the previous version doesn't delete? </p>