其他分享
首页 > 其他分享> > 通知栏

通知栏

作者:互联网

@RequiresApi(api = Build.VERSION_CODES.O)
private void showNotification(){
NotificationChannel notificationChannel=new NotificationChannel("channelId","channelName",NotificationManager.IMPORTANCE_HIGH);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(this).setContentText(getString(R.string.app_name))
.setSmallIcon(R.mipmap.ic_launcher).setWhen(System.currentTimeMillis()).setContentTitle(getString(R.string.app_name))
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher))
.setChannelId("channelId").setAutoCancel(false).build();
manager.createNotificationChannel(notificationChannel);
manager.notify(1001,notification);
}

标签:NotificationManager,通知,app,channelId,manager,notificationChannel,ic
来源: https://www.cnblogs.com/qynprime/p/14522163.html