首页 > 移动平台 > 详细

Android中使用Notifaction无反应

时间:2016-04-20 14:58:55      阅读:267      评论:0      收藏:0      [点我收藏+]
时间:2016-4-20 11:07:29

使用Notifaction.Builder()触发时无反应,是否设置图标Icon?
  1. builder.setSmallIcon(R.drawable.ic_launcher);
如果没有设置Icon就会出现触发时无反应。

完整地code样式:
  1. Intent intent = new Intent(context, XXActivity.class);
  2. intent.putExtra("recFile", recName);
  3. PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  4. NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
  5. Notification.Builder builder = new Notification.Builder(context);
  6. builder.setTicker("新的通知");
  7. builder.setSmallIcon(R.drawable.ic_launcher);
  8. builder.setContentTitle("收到新的通知");
  9. builder.setContentText("您有一条新的通知");
  10. builder.setContentIntent(pendingIntent);
  11. Notification notification = builder.build();
  12. notification.flags = Notification.FLAG_AUTO_CANCEL;
  13. manager.notify(NOTIFACTION_FLAG_CODE, notification);





Android中使用Notifaction无反应

原文:http://www.cnblogs.com/yuzhongzheng/p/5412587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!