android 8.0 Notification

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Leif_dong/article/details/84925883
private void updateSuccessNotification(boolean isPass){
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            String id = "update_success";
            String name = "update_success_notification";
            NotificationManager notificationManager = (NotificationManager) mSystemContext.getSystem
Service(NOTIFICATION_SERVICE);
            Notification notification = null;
            NotificationChannel mChannel = null;
            mChannel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW);
            notificationManager.createNotificationChannel(mChannel);
            if(isPass) {
                notification = new Notification.Builder(mSystemContext)
                        .setChannelId(id)
                        .setContentTitle(mSystemContext.getString(R.string.global_update_success))
                        .setContentText(mSystemContext.getString(R.string.global_current_version)+Bu
ild.VERSION.INCREMENTAL)
                        .setSmallIcon(R.drawable.btn_default).build();
                notificationManager.notify(111123, notification);
            }else{	
                notificationManager.createNotificationChannel(mChannel);
                notification = new Notification.Builder(mSystemContext)
                        .setChannelId(id)
                        .setContentTitle(mSystemContext.getString(R.string.global_update_fail))
                        .setContentText(mSystemContext.getString(R.string.global_current_version)+Bu
ild.VERSION.INCREMENTAL)
                        .setSmallIcon(R.drawable.btn_default).build();
                notificationManager.notify(111123, notification);
            }	
			        }	
    }

 

展开阅读全文

没有更多推荐了,返回首页