我已经成功地从示例中实现了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);