应用弹出通知时会自动消失,大概5秒钟,怎么让其一直显示在顶部呢
if (VERSION.SDK_INT >= 26) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, NOTI_PUSH_CHANNEL, NotificationManager.IMPORTANCE_HIGH);
notificationChannel.setDescription(context.getString(R.string.app_name));
if (notificationManagerCompat != null) {
notificationManagerCompat.createNotificationChannel(notificationChannel);
}
}
Notification notification = (new Builder(context, CHANNEL_ID)).setSmallIcon(R.mipmap.ic_launcher)
.setPriority(1)
.setContentIntent(pendingIntent)
.setCustomContentView(remoteViews)
.setFullScreenIntent(pendingIntent, true).build();
if (notificationManagerCompat != null) {
notificationManagerCompat.notify(NOTIFICATION_REMINDER_ID, notification);
}
这是相关属性,后来发现 少申请了一个权限
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
加上之后 就不会自动消失了