-1

我有一个通知栏(每天 2 个事件)。字符串数组的小列表,获取随机数的方法和下面的代码。

我需要可以单击事件并在该活动(not1 [x])上打开一个带有字符串变量显示的新活动。

会怎么做?

随机的();

String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
        int icon = R.drawable.ic_launcher2;
        CharSequence tickerText = not1[x];
        long when = System.currentTimeMillis();
        Notification notification = new Notification(icon, tickerText, when);
        CharSequence contentTitle = "Title";
        CharSequence contentText = not1[x];;
        Intent notificationIntent = new Intent();
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        final int HELLO_ID = 1;
        mNotificationManager.notify(HELLO_ID, notification);
4

1 回答 1

1

只是改变你的代码

Intent notificationIntent = new Intent(context,yourActivityclass);
   PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0);

只需使用字符串的代码

Intent i = new Intent();
i.putExtra("key", stringValue);

Intent other = new Intent()
other.getStringExtra(key)
于 2012-12-14T19:51:06.550 回答