Redirecting this back to the list where it belongs...
On Tue, Jul 19, 2011 at 9:15 AM, Mark Woollard <[email protected]> wrote:
> Sorry for being dense but not totally clear on what you are saying. Here is
> the code extract that creates the notifications. If you could advise what
> needs changing it would be a great help. Thanks for taking the time to look
> at this so far.
> Notification notification = new Notification(resourceId, title,
> System.currentTimeMillis());
> notification.contentView = contentView;
> Context context = getApplicationContext();
> Intent notificationIntent = new Intent(context, SiteActivity.class);
> Long siteId = Long.valueOf(site.getString(site.getColumnIndex("_id")));
> Log.i(TAG,"Site id " + siteId);
> notificationIntent.putExtra("site", siteId);
> notificationIntent.putExtra("region",
> Long.valueOf(site.getString(site.getColumnIndex("region_id"))));
> PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
> notificationIntent, 0);
Every time you execute this block of code, while you *think* you are
creating new extras, you are not. getActivity() does *NOT* return a
new PendingIntent for a previously-created Intent.
If you are displaying these notifications serially (i.e., only one is
on-screen at a time), simply use FLAG_UPDATE_CURRENT in the
getActivity() call, to have your new extras be used.
If you are displaying these notifications concurrently (i.e., 2+ will
be on-screen at a time), then you need to use Intents that differ by
more than their extras.
Also, please do not use getApplicationContext() if you don't have a
specific and concrete reason. Whatever Context you are in will be fine
for the Notification, so please use:
Intent notificationIntent = new Intent(this, SiteActivity.class);
and so on.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
Warescription: Three Android Books, Plus Updates, One Low Price!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en