阅读Android Notifications的全文?

时间:2012-02-17 08:47:05

标签: android android-notifications

我正在寻找一种阅读通知全文的方法,因为包含大量文字的通知会被裁剪:

Notification with large amount of text

是否可以强制通知栏展开以适合文本? 也许有办法在某处访问它们的日志?

我见过有人问如何在没有任何运气的情况下显示较长文本的通知: Android multiline notifications / notifications with longer text

如果没有找到触发它们的应用程序,是不是真的没有办法读取它们?

5 个答案:

答案 0 :(得分:2)

嘿,我一直在寻找,并发现论坛上有人说你必须使用轨迹球或箭头突出显示它并且长时间不起作用。但是过了一段时间我厌倦了并且即将放弃并决定再次尝试长按并且它有效!大声笑你必须长按并保持5秒钟

答案 1 :(得分:1)

试试这个,

    Notification notification = new Notification.Builder(currentContext)
            .setSmallIcon(R.drawable.ic_launcher)
            .setStyle(
                    new Notification.BigTextStyle()
                            .bigText(
                                    "Your lengthy text here")
                            .setBigContentTitle("Your title!!!")
                            .setSummaryText("Wonderful summary here"))
            .setAutoCancel(true).setContentIntent(pendingIntent).build();
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_LIGHTS;
    notificationManager.notify(NOTIFICATION_ID, notification);

我使用过的代码,显示整个文本而不截断。 我已经在最低sdk 4.4.2的应用程序中使用它并且工作正常。

答案 2 :(得分:0)

我还没有这样做,但我相信如果您在创建通知时指定了RemoveViews,则可以指定在显示通知时使用的视图。您可以使用它来扩展超出当前默认大小的那个。

请参阅 http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification

答案 3 :(得分:0)

自定义通知视图的高度似乎有限制。 This answer表示限制为65 sp。最糟糕的部分是官方文档没有在任何地方提到它。

答案 4 :(得分:0)

https://stackoverflow.com/a/29364414/1025379

sbn.getNotification().extras.getCharSequence(Notification.EXTRA_TEXT).toString();