mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.cancelAll();
String title = getString(R.string.filtershow_notification_label); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { String id = "channel_1"; NotificationChannel channel = new NotificationChannel(id, title, NotificationManager.IMPORTANCE_HIGH); mNotifyMgr.createNotificationChannel(channel); mBuilder = new Notification.Builder(this, id) .setCategory(Notification.CATEGORY_EVENT) .setSmallIcon(R.drawable.filtershow_button_fx) .setContentTitle(title) .setContentText(getString(R.string.filtershow_notification_message)) .setAutoCancel(true); } else { mBuilder = new Notification.Builder(this) .setSmallIcon(R.drawable.filtershow_button_fx) .setContentTitle(title) .setContentText(getString(R.string.filtershow_notification_message)); }
mNotifyMgr.notify(mNotificationId, mBuilder.build());
mNotificationId為1的話,systemui下拉欄會存在對應的通知item(可以用來點擊跳轉),
如果是0的話,則不會出現.
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/43783.html
標籤:Android
上一篇:APK簽名替換檢測
