当我收到GCM消息时,我必须在我的应用程序中显示通知。 所以我在android中编写了一个notificaiton代码。问题是
1。在某些设备上,通知未显示 的 2。在某些设备上,即使我点击通知时显示通知,也不显示FragmentActivity所需的片段。
这些问题仅发生在某些设备
中这是我的代码:
Context context = ctx;
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(
R.drawable.launcher_icon, "Notification message",
System.currentTimeMillis());
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("com.friends.with.benefits.bang.facebook.dating.matchFbId", userID);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pIntent = PendingIntent
.getActivity(context, 0, intent,0);
notification.setLatestEventInfo(context, "FriendsWithBenefits",
"Hurray! You have a match on FriendsWithBenefits. Click here to check it out!", pIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notificationManager.notify(i++, notification);
我不知道为什么它只在某些设备上发生?