通知栏

@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);
}
上一篇:如何解决netty自定义协议粘包分包问题


下一篇:knockoutJS-04之observableArray监控数组