title: how to intent the same activity instead of second activity
body: <p>I want to intent same activity such as MainActivity->MainActivity instead of MainActivity->SecondActivity</p>
  
  <p>Her is my code, but it doesn't work, it will stop my app, how to fix it</p>
  
  <pre><code> public class AddasMessage extends AsyncTask&lt;AddMessage,Long,JSONArray&gt;
  {
      ProgressDialog dialog = new ProgressDialog(FriendDetailsActivity.this);
  
  
      protected void onPreExecute(){
          dialog.setMessage("Adding...");
          dialog.show();
      }
      @Override
      protected JSONArray doInBackground(AddMessage... params) {
  
          // it is executed on Background thread
  
          return params[0].AddtobeMessage();
  
  
      }
  
      @Override
      protected void onPostExecute(JSONArray jsonArray) {
          Log.i("Main activity", String.valueOf(jsonArray));
          dialog.dismiss();
  
          Intent intent = new Intent(getBaseContext(), FriendDetailsActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          startActivity(intent);
          Context context = getApplicationContext();
          CharSequence text = "You are success to send the message!";
          int duration = Toast.LENGTH_SHORT;
  
          Toast toast = Toast.makeText(context, text, duration);
         toast.show();
  
  
  
      }
  
  
  
  }
  </code></pre>