1
我想通過以下代碼擴展通知,如果文本很長。具有展開通知的NotificationCompat.Builder不起作用
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(getNotificationIcon())
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
.setContentTitle(getString(R.string.app_name))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
但它顯示單行通知並且無法展開它。我的測試設備是棉花糖。
要顯示默認大牌風範notifcation請看看以下網址http://stackoverflow.com/questions/23331682/我您的問題明白了什麼is-possible-set-expanded-notification-as-default-in-big-text-notifications – Sam
@Sam我提到這個鏈接不適合我。 –