0
我想將廣播接收器中的字符串傳遞給活動。當我點擊通知時,我提出了一個通知。我開始在該活動的活動我想顯示字符串數組值:如何通過通知將字符串數組從BroadcastReceiver傳遞給Activity類
我寫一個類廣播接收器的,如下圖所示:如圖所示
public class RepeatingAlarm extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
String array[5]={"hai","hello","how r u?","welcome"};
//i am calling notification method here
notification();
}
}
我有寫一個方法得到通知低於
public static void myNotify(Context context,String message)
{
NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon,"A new notification", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
//Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(""));
Intent notificationIntent = new Intent(context.getApplicationContext(), CustomDialogExample.class);// i am starting CustomDialogExample
PendingIntent activity = PendingIntent.getActivity(context,0,notificationIntent, 0);
notification.setLatestEventInfo(context,"Notification for you",message,activity);
notification.number += 1;
notificationManager.notify(0, notification);
}
從上面的方法我開始CustomDialogExample活動。當我點擊Notification時,我想獲得RepeatingAlarm類arra []將會在CustomDialogExample類中獲得。
請任何機構幫助我
這裏我怎樣才能得到在ExampleActivity.class.please的字符串可以給你清晰的字符串在另一個活動 –