我想将一个字符串从广播接收器传递到activity。当我点击通知时,我提出了一个通知。我正在启动一个活动,在该活动中,我想显示字符串数组值:
我已经编写了一个BroadcastReceiver类,如下所示:
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时,我想要获取arra[]将在CustomDialogExample类中获得的RepeatingAlarm类。
请任何人帮助我
发布于 2011-08-27 19:41:48
为此,您应该使用Intent.putStringArrayListExtra()函数。下面是一个例子:
ArrayList<String> strings = new ArrayList<String>();
strings.add("item1");
...
strings.add("itemN");
notificationIntent.putStringArrayListExtra("stringArrayArg", strings);https://stackoverflow.com/questions/7214252
复制相似问题