通过单击通知拖动中的选项卡打开(警报)对话框

时间:2012-11-11 18:29:23

标签: android notifications push-notification google-cloud-messaging

我已经成功地从示例中实现了gcm并且可以收到通知消息,但是当我从栏中向下拖动时,文本的一部分会显示在选项卡中。

单击选项卡并显示整条信息时,我无法弄清楚如何打开(警报)对话框。

任何? 感谢荷兰!

protected void onMessage(Context arg0, Intent arg1) {
Log.i(TAG, "new message= ");
String ticker=arg1.getExtras().getString("ticker");
String subject=arg1.getExtras().getString("subject");
String message=arg1.getExtras().getString("message");

Vibrator vibrator = (Vibrator) arg0.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000);

String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = ticker;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = subject;
CharSequence contentText = message;
Intent notificationIntent = new Intent(this, FragmentActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);

1 个答案:

答案 0 :(得分:0)

PendingIntent需要是SystemUI可以从包外部开始的,所以请确保在清单中声明了类。

更多信息可在Notifications guide

中找到
相关问题