title: Bring my Activity back to the top?
body: <p>This question is a spin-off from a suggestion made in <a href="https://stackoverflow.com/questions/11439833/how-to-close-or-stop-an-external-app-that-i-started-in-android">How to close or stop an external app that I started in Android</a>.</p>
  
  <p>I'm writing an Android  app which is a remote-control for an industrial process - the process runs on a PC which is in constant communication with my Android app,    Occasionally the PC sends a PDF file to the Android and I launch the AdobeReader.apk to display it.   When the PC dismisses the image I want to dismiss it on the Android.</p>
  
  <p>In the link above I was told that once I launch the AdobeReader there's no way to shut it down from my code.  <strong>However</strong> I might be able to bring my app back to the front, which is just as good for my purposes.  But I haven't been able to get it to work.   The main activity for my app is RemoteControlActivity and I tried:</p>
  
  <pre><code>try {
     Intent i = new Intent(ctx, RemoteControlActivity.class);
     ctx.startActivity(i);    
  }   
     catch (ActivityNotFoundException e)   {
     Log.d("ShowButtons(normal)", "Hide");
  }
  </code></pre>
  
  <p>I also tried adding an <em>intent.setFlags(...)</em> before the <em>startActivity(</em>) call with various combinations of <strong>Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_FROM_BACKGROUND</strong> with no luck.</p>
  
  <p>In the manifest the launch mode for remoteControlActivity is <strong>singleTask</strong></p>
  
  <p>In the debugger the <em>StartActivity()</em> is called without landing in the Catch clause but I don't hit a breakpoint in RemoteControlActivity's onRestart or onResume handlers.</p>
  
  <p>Thanks in advance!  </p>
  
  <p><strong>EDIT:</strong>  An answer, below, suggested a different flag so I tried it:</p>
  
  <pre><code>try {
      Intent i = new Intent(ctx, RemoteControlActivity.class);
      i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
      ctx.startActivity(i);          
  }   
  catch (ActivityNotFoundException e) {
      Log.d("ShowButtons(normal)", "Hide");
  }
  </code></pre>
  
  <p>... but no luck -  in the debugger it calls startActivity, does not land in the catch block, but nothing happens.</p>
  
  <p><strong>Further Edit</strong>:  I was asked for the Manifest; here's the part for the main Activity:</p>
  
  <pre><code>&lt;activity android:launchMode="singleTask"
      android:label="@string/app_name"
      android:windowNoTitle="false"
      android:configChanges="orientation"
      android:screenOrientation="landscape"
      android:name="RemoteControlActivity"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;  
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  </code></pre>