帮我这个,我犯了错误……?
private static voID generateNotification(Context context,String message) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(context,GCMMessageVIEw.class); String[] messageArray = message.split("\#"); // param :: agentID,name,Msg DatabaseHelper db = new DatabaseHelper(context); int notificationID = db.insertnotifications(messageArray[1],messageArray[0],messageArray[messageArray.length-1]); notificationIntent.putExtra("message",messageArray[messageArray.length-1]); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); PendingIntent intent = PendingIntent.getActivity(context,notificationIntent,0); Notification notification = new NotificationCompat.Builder(context) .setContentText(messageArray[messageArray.length-1]) .setContentTitle(context.getString(R.string.app_name)) .setSmallicon(icon) .setWhen(when) .setContentIntent(intent) .build(); notification.flags |= Notification.FLAG_auto_CANCEL; // Play default notification sound notification.defaults |= Notification.DEFAulT_SOUND; // Vibrate if vibrate is enabled notification.defaults |= Notification.DEFAulT_VIBRATE; notificationmanager.notify(notificationID,notification);}解决方法 为每封邮件设置唯一的通知ID.因此,它被覆盖了. 总结
以上是内存溢出为你收集整理的android – GCM消息被覆盖?全部内容,希望文章能够帮你解决android – GCM消息被覆盖?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)