Shoutout to @Joseinnewworld – my legendary longtime supporter who just brutally swept my #NFTs like it’s Black Friday
— NFToa (@nftoa_) June 19, 2025
You’re not just a collector, you’re a certified digital art menace 😂🔥
Massive respect – thank you for believing in the vision since day one! 🙌💎 #NFTCommunity pic.twitter.com/dhXCAtloKk
I want to show notification from my service for android O but I got this error and I want to use IMPORTANCE_UNSPECIFIED with notification channel.
This error even appears.
java.lang.IllegalArgumentException: Invalid importance level
As an illustration, my code snippet looks something like this.
if (android.os.Build.VERSION.SDK_INT >= 26) {
try {
// 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);
Notification.Builder builder = new Notification.Builder(this, CHANNEL_ID)
.setSmallIcon(R.mipmap.instant_app_icon)
.setContentTitle(getString(R.string.app_name))
// .setContentText("Instant Service")
.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);
}
catch (Exception ex){
ex.printStackTrace();
}
}Enlightenment
As per the official documentation, you cannot use IMPORTANCE_UNSPECIFIED, here is a snippet.
added in API level 24 int IMPORTANCE_UNSPECIFIED Value signifying that the user has not expressed an importance. This value is for persisting preferences, and should never be associated with an actual notification. for more info you can read here https://developer.android.com/reference/android/app/NotificationManager.html#IMPORTANCE_UNSPECIFIED
Instead you can use one of the importance levels below.
- IMPORTANCE_DEFAULT
- IMPORTANCE_HIGH
- IMPORTANCE_LOW
- IMPORTANCE_MAX
- IMPORTANCE_MIN
