如何显示这样的通知或 IMPORTANCE_UNSPECIFIED?

How to display notification like this or with IMPORTANCE_UNSPECIFIED?

如何显示像质量时间这样的通知。我使用下面的代码来显示通知,但它给我 IllegalArgumentException: Invalid importance level

mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.app_name);
// Create the channel for the notification
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name,
        NotificationManager.IMPORTANCE_UNSPECIFIED);

// Set the Notification Channel for the Notification Manager.
mNotificationManager.createNotificationChannel(mChannel);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
        .setContentTitle(getString(R.string.app_name))
        .setAutoCancel(true);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(
        this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentIntent(contentIntent);

Notification notification = builder.build();
startForeground(1, notification);

得到这个错误:

java.lang.IllegalArgumentException: Invalid importance level 
at android.os.Parcel.readException(Parcel.java:1950)
at android.app.INotificationManager$Stub$Proxy.createNotificati‌onChannels(INotifica‌tionManager.java:155‌6)
at android.app.NotificationManager.createNotificationChannels(N‌otificationManager.j‌ava:453) 
at android.app.NotificationManager.createNotificationChannel(No‌tificationManager.ja‌va:441) 
at com.app.MyService.onCreate(ScreenService.java:167) –
Add Comment Collapse

你应该使用NotificationManager.IMPORTANCE_MIN

IMPORTANCE_MIN

added in API level 24 int IMPORTANCE_MIN Only shows in the shade, below the fold.

https://developer.android.com/reference/android/app/NotificationManager.html#IMPORTANCE_MIN