赞
踩
- Context context = APPContext.getContext();
- NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- Intent intent = new Intent(context, HomeActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
- PendingIntent pend = PendingIntent.getActivity(context, R.string.app_name, intent, PendingIntent.FLAG_UPDATE_CURRENT);
-
- String appName = APPContext.getContext().getResources().getString(R.string.app_name);
- Bitmap bitmap = BitmapFactory.decodeResource(APPContext.getContext().getResources(), R.mipmap.ic_launcher);
-
- NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
- mBuilder.setContentTitle(appName)//设置通知栏标题
- .setContentText(text)//通知栏中标题下面的内容
- .setLargeIcon(bitmap)//设置大图标
- .setContentIntent(pend) //设置通知栏点击意图
- .setTicker(text) //通知首次出现在通知栏,带上升动画效果的
- .setWhen(System.currentTimeMillis())//通知产生的时间,会在通知信息里显示,一般是系统获取到的时间
- .setPriority(Notification.PRIORITY_DEFAULT) //设置该通知优先级
- .setSmallIcon(R.mipmap.icon_notice_logo);//设置通知小ICON
- manager.notify(USERCENTER_NOTIFICATION,mBuilder.build());
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。