我为我的应用程序实现了Android通知,用于解析推送通知。但最近我发现通知内容在KitKat系统上无法显示,只有在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"
...
这个差异是怎么回事呢?非常感谢您的帮助。