views:

43

answers:

1

When my notification goes off I want to restore the activity that was put into the background, not start a new activity. I've seen some answers about using FLAGS but I don't know how to implement it

contentIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | INTENT.FLAG_ACTIVITY_SINGLE_TOP);

Where do I put this in my code? I tried but it didn't work. Please help!

        ns = Context.NOTIFICATION_SERVICE;
        mNotificationManager = (NotificationManager) getSystemService(ns);
        icon = R.drawable.icon;
        tickerText = "Short Msg";
        when = System.currentTimeMillis();
        notification = new Notification(icon, tickerText, when);
        context = getApplicationContext();
        contentTitle = "MyApp";
        contentText = "Reopen App";
        notification.defaults |= Notification.DEFAULT_SOUND;
        notification.defaults |= Notification.DEFAULT_VIBRATE;
        notificationIntent = new Intent(this, StartTimer.class);
        contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
+1  A: 

Figured it out, set the Activity to SingleTop or SingleInstance in Android Manifest, then instead of creating a new activity it just reopen the one still active.

Cameron