5

通知を使用して複数行のテキストを表示しようとしていますが、表示BigTextStyleできません。以下のコードを使用しています。

public void sendNotification(View view) {
    String msgText = "Jeally Bean Notification example!! "
            + "where you will see three different kind of notification. "
            + "you can even put the very long string here.";

    NotificationManager notificationManager = getNotificationManager();
    PendingIntent pi = getPendingIntent();
    android.app.Notification.Builder builder = new Notification.Builder(
            this);
    builder.setContentTitle("Big text Notofication")
            .setContentText("Big text Notification")
            .setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true)
            .setPriority(Notification.PRIORITY_HIGH)
            .addAction(R.drawable.ic_launcher, "show activity", pi);
    Notification notification = new Notification.BigTextStyle(builder)
            .bigText(msgText).build();

    notificationManager.notify(0, notification);
}

public NotificationManager getNotificationManager() {
    return (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}

public PendingIntent getPendingIntent() {
    return PendingIntent.getActivity(this, 0, new Intent(this,
            MainActivity.class), 0);
}

通知に「msgText」すら表示されません。理由はありますか?助けてくれてありがとう。

4

4 に答える 4

0

コンテンツ インテント値も設定してみてください。

Notification.Builder builder = new Notification.Builder(this);
builder.setContentTitle("Big text Notification")
        .setContentText("Big text Notification")
        .setSmallIcon(R.drawable.ic_launcher)
        .setAutoCancel(true)

        .setContentIntent(pi) // <- this new line

        .setPriority(Notification.PRIORITY_HIGH)
        .addAction(R.drawable.ic_launcher, "show activity", pi);
于 2014-01-30T06:45:51.613 に答える
-4

.setPriority(Notification.PRIORITY_HIGH)- この行は私の問題を解決しました。複数行の保存サイズ。

于 2015-11-04T20:37:26.063 に答える