Ank*_*oor 9 android android-notifications
如何在顶部显示Android通知?
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);
Run Code Online (Sandbox Code Playgroud)
PRIORITY_MAX此常量在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);
Run Code Online (Sandbox Code Playgroud)
https://developer.android.com/reference/android/app/Notification.html#PRIORITY_MIN