为什么安卓通知文本没有显示?

3
我已经编写了以下通知代码,我能够看到通知和通知的标题,但是正文内容不可见。我尝试过多次使用静态值,但仍然无法找出问题所在。请帮我一下,提前致谢。
private void messagenotification(String msg, String nextid) {


    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString("id", nextid  ).apply();

    Intent intent = new Intent(this, NextActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.blue)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.blue))
            .setContentTitle("Chat")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);



    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
1个回答

7

看起来你在通知构建器中忘记了 .setContentText("Example")

文档在这里


谢谢您的回复,让我来确认一下。 - Adarsh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接