关于发送多条notifications所遇到的一些问题 2
2013-10-29 16:18
363 查看
NotificationManager mNotificationManager =(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); Intent mIntent = new Intent(context, MainActivity.class); mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mIntent.putExtra(TAG, GCM); mIntent.putExtra(MESSAGE_ID, message_id); mIntent.putExtra(TITLE, title); mIntent.putExtra(TEXT, msg); int requestID = (int) System.currentTimeMillis(); PendingIntent contentIntent = PendingIntent.getActivity(context, requestID, mIntent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setContentTitle(title) .setContentText(msg) .setSmallIcon(R.drawable.ic_launcher) .setAutoCancel(true) .setLights(Color.parseColor("#2E6AD7"), 5000, 5000) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); mBuilder.setContentIntent(contentIntent); SharedPreferences prefs = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE); int notifiId = prefs.getInt("notifiId_count", 0); notifiId = notifiId + 1; mNotificationManager.notify(notifiId,mBuilder.build()); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("notifiId_count", notifiId); editor.commit();
相关文章推荐
- 关于发送多条notifications所遇到的一些问题
- Java中关于空格遇到的一些问题
- 关于android ListView倒计时遇到的一些问题
- 我遇到的一些问题的解决答案,有关于操作系统中的
- 关于在项目中遇到的一些兼容性问题----img
- 关于JAVA MAP中经常遇到的一些问题及解决方法
- 关于Android Studio 导入Library Project 以及遇到的一些问题
- 最近遇到不少客户提出关于PP账户名字需要更改,如何更改的问题。因此在此做个简单的总结,希望能帮到一些朋友!
- 关于把.net 2.0的项目升级到.net4.0遇到的一些问题
- 关于Xcode提高读写速度遇到的问题和一些想法
- 关于php socket编程中遇到的一些问题
- 关于一些平常JAVA知识及遇到问题的积累(持续更新)
- 关于java学习之中遇到的一些问题之:java.util.NoSuchElementException.
- 关于通过iText通过HTML转成PDF导出的操作遇到一些问题的记录
- 关于ie6和ie8遇到的一些问题
- 关于Linux安装python画图遇到的一些问题总结
- 关于TSP项目中遇到的一些问题,及解决方法
- 关于推送遇到的一些问题
- 关于使用spring框架来实现email发送其中遇到的问题已解决
- 【IPHONE】关于IPHONE IOS4.0越狱遇到的一些问题汇总