Android 通知内容文本不会显示在 OS 4.4.4 Kitkat 上,但会显示在 OS 5.0 Lollipop 上
Android notification content text wont show up on OS 4.4.4 Kitkat, but shown on OS 5.0 Lollipop
我在我的应用程序上实现了 android 解析推送通知的通知。但是最近我发现 kitkat 上没有显示通知内容。它仅显示在 OS Lollipop 上。
这是图片...
在 Kitkat 4.4.4 上:
在 Lollipop 5.0 上:
两张图片的代码相同:
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
Notification notification = mBuilder.setSmallIcon(smallIcon).setTicker(title) //title
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(title)
.setStyle(inboxStyle)
.setContentIntent(resultPendingIntent)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(notifMessage)
.build();
NotificationManager notificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId, notification);
关于信息,我使用构建工具 23.0.2(写这个问题时最新的)。这是我的应用 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
...
有什么区别?
任何帮助将不胜感激。提前致谢
已解决。仅替换此部分:
.setWhen(System.currentTimeMillis())
这个:
.setWhen(0)
我不知道也不在乎为什么会这样。我认为这是一个错误
我在我的应用程序上实现了 android 解析推送通知的通知。但是最近我发现 kitkat 上没有显示通知内容。它仅显示在 OS Lollipop 上。
这是图片...
在 Kitkat 4.4.4 上:
在 Lollipop 5.0 上:
两张图片的代码相同:
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
Notification notification = mBuilder.setSmallIcon(smallIcon).setTicker(title) //title
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(title)
.setStyle(inboxStyle)
.setContentIntent(resultPendingIntent)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(notifMessage)
.build();
NotificationManager notificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId, notification);
关于信息,我使用构建工具 23.0.2(写这个问题时最新的)。这是我的应用 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
...
有什么区别? 任何帮助将不胜感激。提前致谢
已解决。仅替换此部分:
.setWhen(System.currentTimeMillis())
这个:
.setWhen(0)
我不知道也不在乎为什么会这样。我认为这是一个错误