如何在顶部显示安卓通知?
setPriority(Notification.PRIORITY_MAX)
由于 Notification.PRIORITY_MAX 已弃用,有什么替代方案?
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Notification Title")
.setContentText("Notification Text")
.setPriority(Notification.PRIORITY_MAX)
.setAutoCancel(true);
最佳答案
优先级最大 此常量在 API 级别 26 中已弃用。请改用 IMPORTANCE_HIGH。
PRIORITY_MAX
int PRIORITY_MAX
此常量在 API 级别 26 中已弃用。 请改用 IMPORTANCE_HIGH。
最高优先级,适用于需要用户及时关注或输入的应用程序中最重要的项目。
常数值:2 (0x00000002)
// create ios channel
NotificationChannel iosChannel = new NotificationChannel(IOS_CHANNEL_ID,
IOS_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
iosChannel.enableLights(true);
iosChannel.enableVibration(true);
iosChannel.setLightColor(Color.GRAY);
iosChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
getManager().createNotificationChannel(iosChannel);
https://developer.android.com/reference/android/app/Notification.html#PRIORITY_MIN
关于Android Notification.PRIORITY_MAX 已弃用 在顶部显示通知的替代方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46962253/