Android 8.0 Notifictio 通知音

final String CHANNEL_ID = "com.chao.channel.id";
final String CHANNEL_NAME = "com.chao.channel.name";

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{
/**
 * Oreo不用Priority了,用importance
 * IMPORTANCE_NONE 关闭通知
 * IMPORTANCE_MIN 开启通知,不会弹出,但没有提示音,状态栏中无显示
 * IMPORTANCE_LOW 开启通知,不会弹出,不发出提示音,状态栏中显示
 * IMPORTANCE_DEFAULT 开启通知,不会弹出,发出提示音,状态栏中显示
 * IMPORTANCE_HIGH 开启通知,会弹出,发出提示音,状态栏中显示
 */过
  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);

https://www.cnblogs.com/rchao/p/9057473.html
https://blog.csdn.net/fzkf9225/article/details/81119780
https://blog.csdn.net/androidzmm/article/details/80679804

猜你喜欢

转载自blog.csdn.net/w690333243/article/details/89742346
今日推荐