title: Android: How to start a new activity, but only if it already exists?
body: <p>I am using Android-C2DM, and when I receive a message that has been pushed to my device I want to either update a display (if a certain Activity is visible on the screen) or create a status bar notification (if not).</p>
  
  <p>Everything works besides checking whether or not the Activity is active. What I am looking for is either a way to check if an Activity is active (then I can just surround the code below with an <code>if</code> statement), or if that's not possible I guess I need a different way to go about the whole process.</p>
  
  <p>In C2DMBaseReceiver:</p>
  
  <pre><code>Intent i = new Intent(context, Show.class);
  i.putExtra("id", id);
  i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  context.startActivity(i);
  </code></pre>
  
  <p>In Show.java:</p>
  
  <pre><code>@Override
  protected void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      Log.v(TAG, "onNewIntent");
      // Update the display
  }
  </code></pre>