Сценарий:
У меня запланирован запуск тревоги на указанное количество времени.Каждый раз, когда выполняется мой BroadCastReceiver срабатывает.
В BroadCastReceiver я делаю все виды проверок, и в конце получается ArrayList простых строк
Я отображаю Уведомление в строке состояния
Когда пользователь нажимает на уведомление, я отображаю активность.Мне нужно в своем Activity, ArrayList для отображения его на представлениях.
Вот пример кода:
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);
}
И
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
}
Я пробовал большинство вещей, которые я нашел, от пакетов до putStringArrayListExtra (), но ничего не получалось.В своей деятельности я не могу найти способ получить данные.Пожалуйста, помогите мне, когда я застрял.