为什么Android 7.0(Nougat)中不显示通知文本

时间:2017-03-28 09:53:08

标签: android push-notification android-7.0-nougat

我在我的应用中显示0xA,除了notification以外的所有OS versions中都正常工作( Nougat )以下是​​代码

Android 7.0

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); 我可以看到Android 7.0,标题,但它没有显示完整的通知文字。

notification icon有什么我遗漏的吗?任何帮助都会深深体会。

0 个答案:

没有答案