Scenario:
I have an Alarm scheduled to run on a specified amount of time. Each time is executed, my BroadCastReceiver fires.
In BroadCastReceiver I do all kind of checks and in the end it results a ArrayList of plain Strings
I display an Notification on the Statusbar
When the user taps on a Notification, I display an Activity. I need in my Activity, the ArrayList to display it on views.
Here is the sample code:
public class ReceiverAlarm extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ArrayList<String> notifications = new ArrayList<String>();
//do the checks, for exemplification I add these values
notifications.add("This is very important");
notifications.add("This is not so important");
notifications.add("This is way too mimportant");
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
//init some values from notificationManager
Intent intentNotif = new Intent(context, NotificationViewer.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intentNotif, 0);
Notification notification = new Notification(icon, text, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
}
And
public class NotificationViewer extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.notification_viewer);
//HERE I NEED the ArrayList<String> notifications
}
I tried most of the things I have found around, from bundles to putStringArrayListExtra() but nothing worked. In my Activity I can't find a way to retrieve the data. Please help me as I am stuck.