Skip to content Skip to sidebar Skip to footer

Android Refresh Activity From Notification

I have a program in which I call a notification. The notification, if you pull it down, launches a new activity. mNotificationManager = (NotificationManager) getSystemService(ns);

Solution 1:

Apparently this is actually a bug/feature of the android environment. Unless a pendingIntent() is passed with a unique requestCode, it simply retrieves the old intent that was originally passed with that number.

Details can be found here: http://groups.google.com/group/android-developers/browse_thread/thread/ad855bb57042c2bd/e84c8d6fececf6e4?lnk=gst&q=notification#e84c8d6fececf6e4

The solution they came up with was to simply increment the requestCode every time pendingIntent.getActivity(Context context, int requestCode, Intent intent, int flags) is called, and set the flags the way I had done it originally with

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Which, doesn't seem like a perfect solution, but it works. Thank you guys for your help!

Solution 2:

I think, first of all, you should forget about the FLAG_ACTIVITY_NEW_TASK, cause this would open a new task (group of activities) without clearing anything you previously opened. The FLAG_ACTIVITY_CLEAR_TOP wouldn't vbe useful for you either, cause, if I understand the scenario correctly your taks has only two activities, and your target activity is the secondary.

So here it's my question... If the second piece of code is executed within an Activity context, why don't you just call startActivity with the new extras? This would allow you to handle the new extras on the onStart method of the secondary activity.

Regards.

Solution 3:

Are you overriding onNewIntent() to catch the new intent, or just calling getIntent()? The onNewIntent() documentation says that getIntent() will continue to return the original intent used to launch the activity, unless you call setIntent() from onNewIntent().

Post a Comment for "Android Refresh Activity From Notification"