仍然不显示可扩展内容
Still not display expandable content
我的代码:
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "channel_name";
String description = "channel_description";
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(default_notification_channel_id, name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, default_notification_channel_id)
.setSmallIcon(R.drawable.logo_mobile_main_btn)
.setContentTitle("textTitle")
.setContentText("textContent")
.setStyle(new NotificationCompat.BigTextStyle().bigText("Much longer text that cannot fit one line.Much longer text that cannot fit one line.Much longer text that cannot fit one line."))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
// notificationId is a unique int for each notification that you must define
notificationManager.notify(( int ) System. currentTimeMillis () , builder.build());
问题:只显示“textTitle”和“textContent”
我预计:显示 bigText
我错了吗?
是版本变更的问题,我已经解决了!
我的代码:
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "channel_name";
String description = "channel_description";
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(default_notification_channel_id, name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, default_notification_channel_id)
.setSmallIcon(R.drawable.logo_mobile_main_btn)
.setContentTitle("textTitle")
.setContentText("textContent")
.setStyle(new NotificationCompat.BigTextStyle().bigText("Much longer text that cannot fit one line.Much longer text that cannot fit one line.Much longer text that cannot fit one line."))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
// notificationId is a unique int for each notification that you must define
notificationManager.notify(( int ) System. currentTimeMillis () , builder.build());
问题:只显示“textTitle”和“textContent” 我预计:显示 bigText
我错了吗?
是版本变更的问题,我已经解决了!