Search code examples
androidandroid-5.0-lollipopandroid-notificationsandroid-4.4-kitkat

Android notification content text wont show up on OS 4.4.4 Kitkat, but shown on OS 5.0 Lollipop


I implement android notification for parse push notification on my app. But recently I realize the notification content not shown on kitkat. it's only shown on OS Lollipop.

here's the image ...
on Kitkat 4.4.4 :
on kitkat 4.4.4

on Lollipop 5.0:
enter image description here

The code is the same for both image:

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);

for info, I use build tools 23.0.2 (newest when this question written). here is my app build.gradle:

apply plugin: 'com.android.application'

android {
         compileSdkVersion 23
         buildToolsVersion "23.0.2"
...

what's up with the difference? any help will be appreciated. thanks in advance


Solution

  • solved. by only replace this part:

    .setWhen(System.currentTimeMillis())
    

    with this one:

    .setWhen(0)
    

    I dont know & dont care why this happened. I think it's a bug