1

当我收到 GCM 消息时,我必须在我的应用程序中显示通知。所以我在android中编写了一个通知代码。问题是

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);

我不知道为什么它只发生在某些设备上?

4

0 回答 0