when we pass 0 as flag to PendingIntent as below :
PendingIntent pi=PendingIntent.getActivity(this, 1, i, 0);
does it follow any flags rules means does 0 correspond to any flag by default.
If we create another PendingIntent as
PendingIntent pii=PendingIntent.getActivity(this, 1, i, 0);
will it be same as earlier and if i make any change to the data in Intent , will it now correspond to new data in Intent or still have old data.
Another problem i am facing in this is I am trying to check flag
PendingIntent.FLAG_NO_CREATE
I have written the following code :
Intent i=new Intent(this,NotifResult.class);
i.putExtra("number",50);
PendingIntent pi=PendingIntent.getActivity(this, 1, i, 0);
NotificationCompat.Builder nb=new NotificationCompat.Builder(this);
nb.setSmallIcon(R.drawable.ic_launcher);
nb.setTicker("ticker is here");
nb.setWhen(System.currentTimeMillis())
.setContentTitle("just the title")
.setContentText("and the description")
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setContentIntent(pi);
Notification notif=nb.build();
NotificationManager nm=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(11, notif);
i.putExtra("number",80);
PendingIntent pisecond=PendingIntent.getActivity(this, 1, i, PendingIntent.FLAG_NO_CREATE);
if(pi.equals(pisecond))
Log.v("check","they are equal");
else
Log.v("check", "they are not equal");
notif.contentIntent=pisecond;
nm.notify(11, notif);
As per docs , PendingIntent.FLAG_NO_CREATE does not create any new object if there is an existign object. i am printing value of number in the NotifResult activity wherein number value is coming to be 80 rather than 50 expected as it should use existing intent with old value ( as per my understanding).kindly update why output is coming 80. the log is showing objects to be equal as expected.
thanks