码迷,mamicode.com
首页 > 移动开发 > 详细

android notification 重启app不重载

时间:2015-07-28 22:46:02      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:

int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
Notification noti = new Notification(icon, contentTitle, when);
noti.flags |= flag;
 
PackageManager pm = context.getPackageManager();
Intent notificationIntent = pm.getLaunchIntentForPackage(context.getPackageName());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
notificationIntent.putExtra("notificationTag", tag);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
 
noti.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

上面的方法解决不了


   notificationIntent.setAction(Intent.ACTION_MAIN); 
                
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); 

这样就可以了 

 

android notification 重启app不重载

标签:

原文地址:http://www.cnblogs.com/yujian-bcq/p/4684308.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!