// Intent intent = new Intent(); // intent.putExtra(EventBusCustom.key_cancelAppointBean, EventBusJpush.s_cancel_appoint); // EventBus.getDefault().post(new EventBusJpush(EventBusJpush.s_cancel_appoint, id)); //获取PendingIntent // Intent mainIntent = new Intent(mContext, cancelAppointReceiver.getClass()); // mainIntent.putExtra(EventBusCustom.key_cancelAppointBean, aNo); // PendingIntent mainPendingIntent = PendingIntent.getBroadcast(mContext, 0, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT); //创建 Notification.Builder 对象 NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext, "cancelAppoint") .setSmallIcon(R.mipmap.fengchaoicon) //点击通知后自动清除 .setOngoing(true) .setAutoCancel(true) .setContentTitle("预约超时提醒") .setContentText("您预约的充电桩已超时,系统已自动为您取消预约") .setPriority(NotificationCompat.PRIORITY_MAX) .setDefaults(Notification.DEFAULT_ALL); // .setContentIntent(mainPendingIntent); NotificationManager mNotifyManager = (NotificationManager) mContext.getSystemService(mContext.NOTIFICATION_SERVICE); //发送通知 Notification build = builder.build(); build.flags = Notification.FLAG_AUTO_CANCEL; mNotifyManager.notify(1, build);
Android Notification
最新推荐文章于 2023-02-14 19:22:04 发布