Android how to create notification that resumes activity

Posted by Adam Praiswater on Stack Overflow See other posts from Stack Overflow or by Adam Praiswater
Published on 2014-08-22T16:10:45Z Indexed on 2014/08/22 16:20 UTC
Read the original article Hit count: 222

Filed under:
|

I a have a notification in a receiver that fires off fine, but it restarts the activity (thus clearing the edittexts and resetting the toggle button) How can i set it so that when its tapped on it resumes the activity rather that clearing and resetting everything? My current code doesnt work.

Current Code

String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
        Intent intenti= new Intent(context, Locator.class);
        intenti.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                intenti, 0);

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.xxxxxxnotifyicon)
                        .setContentTitle("xxxxxxx Link")
                        .setContentText("Auto Check In Complete at " + currentDateTimeString);
        mBuilder.setContentIntent(contentIntent);
        mBuilder.setDefaults(Notification.DEFAULT_SOUND);
        mBuilder.setAutoCancel(true);
        NotificationManager mNotificationManager =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(1, mBuilder.build());

© Stack Overflow or respective owner

Related posts about java

Related posts about android