In my first activity I want to pass two String array lists to another activity, but for some reason when I go to pull the values from the second activity, the bundle loses all the values. Here is the relevant code for sending:
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Bundle b = new Bundle();
b.putStringArrayList("fName", friendNames);
b.putStringArrayList("fIds", friendIds);
Intent intent = new Intent(getApplicationContext(), Friendrequest.class);
PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT).cancel();
intent.putExtras(b);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// creates notification
Notification n = new Notification.Builder(this)
.setContentTitle("You have a friend request!")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent).setAutoCancel(true).build();
notificationManager.notify(0, n);
Here is the relevant code for receiving:
names = new ArrayList<String>();
ids = new ArrayList<String>();
Bundle b = new Bundle();
b = getIntent().getExtras();
names = b.getStringArrayList("fName");
ids = b.getStringArrayList("fIds");
Now, after I create my notification in the first snippet of code, I check to make sure that the "friendNames" array list does indeed contain the correct values and I make a call to b.containsKey("fName")
and it returns true, but as soon as I check the "names" array list in the second snippet of code, none of the values are there and when I make a call to b.containsKey("fName")
it returns false. Any idea what I am doing wrong?