Android - Calling activity with PendingIntent without recreate new one
<p>I needs to reopen an activity when I touch its notification in the notification bar.
The problem is that when the activity is re-opened the dialog that appears need two clicks on the OK button to close it. If the same dialog appears when the activity is still visible then everything works fine.</p>

<p>Could be a Flags problem?</p>

<p>This is what I do to call activity from notification bar:</p>

<pre><code>   void handleCommand(Intent intent) {
    if (ACTION_FOREGROUND.equals(intent.getAction())) {
        // expanded notification
        CharSequence text = "Service started ";

        // Set the icon, scrolling text and timestamp
        Notification notification = new Notification(
                R.drawable.pulsante_piccolo_statusbar, text,
                System.currentTimeMillis());

        // The PendingIntent to launch our activity if the user selects this
        // notification
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, Main.class),0);

        // Set the info for the views that show in the notification panel.
        notification.setLatestEventInfo(this, "Some noticed here!",
                text, contentIntent);
        startForegroundCompat(R.string.foreground_service_started,
                notification);

    } else if (ACTION_BACKGROUND.equals(intent.getAction())) {
        stopForegroundCompat(R.string.foreground_service_started);
    }
}
</code></pre>
