android 通知(android 8.0可用)
Posted 荣超
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android 通知(android 8.0可用)相关的知识,希望对你有一定的参考价值。
final String CHANNEL_ID = "channel_id_1"; final String CHANNEL_NAME = "channel_name_1"; NotificationManager mManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification.Builder builder = null; if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O){ builder = new Notification.Builder(this); }else{ NotificationChannel notificationChannel = new NotificationChannel(Config.CHANNEL_ID, Config.CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); //如果这里用IMPORTANCE_NOENE就需要在系统的设置里面开启渠道, //通知才能正常弹出 mManager.createNotificationChannel(notificationChannel); builder = new Notification.Builder(this,Config.CHANNEL_ID); } notification = builder.build(); mManager.notify(555, notification);
以上是关于android 通知(android 8.0可用)的主要内容,如果未能解决你的问题,请参考以下文章