2

我有一个包含少量文本的通知,但它仍然很大,以便显示在通知栏中,因此它被缩写了。我发现它的唯一解决方案是发出自定义通知,但对于我正在尝试做的事情来说似乎有点矫枉过正。

我可以制作通知滚动文本或扩展通知文本区域,以便它显示全文而不仅仅是它的前几个单词?

我目前通过以下方式调用通知:

private void triggerNotification() {
        Notification notification = new Notification(R.drawable.ic_launcher,
                "Title", System.currentTimeMillis());
        notification.setLatestEventInfo(this, "First text",
                "This is the text that gets abberviated with .. when it is too long",
                PendingIntent.getActivity(this, 0, new Intent(this,MainActivity.class)
                        .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP),
                        PendingIntent.FLAG_CANCEL_CURRENT));
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        nm.notify(0, notification);


}
4

1 回答 1

2

In API 16+, there is a Notification.Builder class that allows you to add a subtext which can be of multiple lines (Like Gmail notifications). I don't know if Notification.Builder is included in the support library but I guess it might be. You can check it.

However, if it is not in the support library and you have to stick to your minSdkVersion, I'm afraid that there is no way to do what you want other than implementing your own notification version.


UPDATE:

The last revision of the support library (revision 10 which was released on August 2012) introduces the Android 4.1 notification style: BigTextStyle. there is a good example of how you can use it. Check it here.

于 2012-08-13T17:57:54.393 回答