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