How create Activity from Notification intent only when it's not already created?
<p>My app creates a <code>Notification</code> from an <code>IntentService</code>. When tapped, the <code>Notification</code> opens <code>MainActivity</code> of type <code>Activity</code>. <code>MainActivity's</code> <code>onCreate()</code> method is called every time a new<code>Notification</code> is tapped, irrespective of whether an instance of<code>MainActivity</code> is already created or not. Tapping the <code>Notification</code> always creates a new instance that replaces the old one.</p>

<p>Is there a way to call <code>onCreate()</code> <i>only if the Activity doesn't exist</i> and call e.g. <code>onNewIntent()</code> if <code>MainActivity</code> already exists (or another appropriate method) ?</p>

<p>The <code>Notification</code> is currently created like this:</p>

<pre><code>    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(com.exampleapp.myclient.R.drawable.dummy_notification_icon, "Notification!", System.currentTimeMillis());
    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
    notification.setLatestEventInfo(context, notificationTitle, "test", pendingIntent);
    notificationManager.notify(1, notification);
</code></pre>

<p><code>MainActivity</code> in Manifest:</p>

<pre><code>&lt;activity android:name="com.exampleapp.myclient.MainActivity"  
    singleTop="true"&gt;
 &lt;/activity&gt;
</code></pre>
