使用Android 2.3.3 SDK扩展通知

时间:2013-01-25 14:13:05

标签: android android-notifications

我在状态栏中收到通知,但如果文本很长,则表示不显示整个文本。我的要求是显示整个文本。我创建了它可以使用Notification Builder完成。如下面的代码:

通知通知= new Notification.BigTextStyle(builder)

但它只会支持Android 3.0及更高版本。现在我无法改变我的sdk,因为有许多我正在使用的东西,如Gallery,已被弃用以上版本。所以请建议我使用Android 2.3.3,我可以实现扩展通知。

先谢谢

1 个答案:

答案 0 :(得分:1)

简短的回答是不,你不能......

长答案是:

您必须更改目标SDK(您仍然可以使用Gallery,但最好重写此代码)

编辑:无论如何,即使在doc,我们也有声明:To maintain your application along with each Android release, you should increase the value of this attribute to match the latest API level, then thoroughly test your application on the corresponding platform version.

正如我在评论中所写的那样在编程中弃用,这意味着try to avoid this class/method, it still will works, but from now, there are better classes/methods for doing this

现在您有两个选择:

首先,使用支持v4库中的NotificationCompat.Builder ...但是在版本低于4.1的设备上,它只显示文本

第二,为版本低于4.1的设备制作自己的自定义通知,并在其他设备上使用新的API ...