Why the notification text is not displayed in Android 7.0 (nougat)

I am showing a notification in my application that works fine on all versions of the OS except Android 7.0 ( Nougat ). Here is the code

  Intent notificationIntent = new Intent(context, HomeScreenActivity.class); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS); Notification.Builder builder = new Notification.Builder(context); builder.setContentIntent(intent) .setAutoCancel(true) .setPriority(Notification.PRIORITY_MAX) .setContentTitle(title) .setStyle(new Notification.BigTextStyle().bigText(message)) .setContentText(message); if (Build.VERSION.SDK_INT >= 21) builder.setVibrate(new long[0]); notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ builder.setColor(context.getResources().getColor(R.color.colorPrimary)); builder.setSmallIcon(R.drawable.ic_nav_reward_point); }else{ builder.setSmallIcon(R.drawable.launcher_icon); } builder.setAutoCancel(true); builder.setContentIntent(intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; // Play default notification sound notification.defaults |= Notification.DEFAULT_SOUND; // Vibrate if vibrate is enabled notification.defaults |= Notification.DEFAULT_VIBRATE; notification = builder.build(); notificationManager.notify(m, notification); 

In Android 7.0 I can see the notification icon, title, but not show the full text of the notification.

Is there something I am missing for Android 7.0 ? Any help would be greatly appreciated.

+5
source share

Source: https://habr.com/ru/post/1266005/


All Articles