title: How to restart activity with singleInstance activity from other activity
body: <p>How to replace or restart activity with singleinstance from another activity.</p>
  
  <p>i have two activity, ActivityA and ActivityB.</p>
  
  <p>in manifest:</p>
  
  <pre><code> &lt;activity
      android:name=".ActivityA"
      android:label="@string/activityA"
      android:launchMode="singleInstance" &gt;
  &lt;/activity&gt;
  &lt;activity
      android:name=".ActivityB"
      android:label="@string/activityB" /&gt;
  </code></pre>
  
  <p>My question, how to restart ActivityA from method in ActivityB.
  Mycode no in ActivityB is:</p>
  
  <pre><code>class ActivityB extends Activity{
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          Button rButton = (Button) findViewById(R.id.restart);
          rButton.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                   restartActivityA();
              }
          });
      }
  
      public void restartActivityA() {
         Intent intent = new Intent(this, ActivityA.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
         startActivity(intent);
         this.finish();
      }
  }
  </code></pre>
  
  <p>If i click the button, so not restart.</p>
  
  <p>Thanks.</p>