android 8.0 Notification

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);
            }	
			        }	
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章