mirror of
https://github.com/danog/termux-api.git
synced 2024-12-03 09:47:52 +01:00
fix notification api piority on Android version>=8
On Android v8 and later, changing priority needs NotificationChannel configuration.
This commit is contained in:
parent
43dec9b13a
commit
6a8d97bd4c
@ -62,8 +62,25 @@ public class NotificationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
String priorityExtra = intent.getStringExtra("priority");
|
||||||
|
if (priorityExtra == null) priorityExtra = "default";
|
||||||
|
int importance;
|
||||||
|
switch (priorityExtra) {
|
||||||
|
case "high":
|
||||||
|
case "max":
|
||||||
|
importance = NotificationManager.IMPORTANCE_HIGH;
|
||||||
|
break;
|
||||||
|
case "low":
|
||||||
|
importance = NotificationManager.IMPORTANCE_LOW;
|
||||||
|
break;
|
||||||
|
case "min":
|
||||||
|
importance = NotificationManager.IMPORTANCE_MIN;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||||
|
}
|
||||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
||||||
CHANNEL_TITLE, NotificationManager.IMPORTANCE_DEFAULT);
|
CHANNEL_TITLE, importance);
|
||||||
manager.createNotificationChannel(channel);
|
manager.createNotificationChannel(channel);
|
||||||
notification.setChannelId(CHANNEL_ID);
|
notification.setChannelId(CHANNEL_ID);
|
||||||
}
|
}
|
||||||
@ -93,7 +110,6 @@ public class NotificationAPI {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
priority = Notification.PRIORITY_DEFAULT;
|
priority = Notification.PRIORITY_DEFAULT;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String title = intent.getStringExtra("title");
|
String title = intent.getStringExtra("title");
|
||||||
|
Loading…
Reference in New Issue
Block a user