How to show Alert dialog when i go from one activity to other?
<p>I have 2 Activities, I want to show Alert dialog when I move from Activity B to Activity A.</p>

<p>This is how I go from one activity to other.</p>

<pre><code>Intent intent = new Intent(Activity_B.this,
    Activity_A.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);                   
</code></pre>

<p>Now when I reach Activity_A, I want to show the alert dialog below.</p>

<pre><code>    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(context.getString(R.string.xxxx));
    builder.setPositiveButton(context.getString(R.string.ok_button), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    alertDialog = builder.create();
    alertDialog.show();
}
</code></pre>

<p>Where should i put this dialog? </p>

<p><strong>EDITED MY QUESTION:-</strong></p>

<p>Here is My Flow</p>

<p>Activity A > Activity B (10 fragments) > Activity A </p>

<p>Now When i move from Activity B to Activity A , after Activity A launches I want to show alert dialog.
Note : Only when I move from Activity B to Activity A.</p>