究竟如何使用Notification.Builder如何使用、Notification、Builder

由网友(ソ信命不认命ペ)分享简介:我发现我使用的是德precated方法noficitations(notification.setLatestEventInfo())报告说,使用Notification.Builder。 如何使用它?当我尝试创建一个新的实例,它告诉我:Notification.Builder不能被解析为一个类型解决方案 从http:...

我发现我使用的是德precated方法noficitations(notification.setLatestEventInfo())

报告说,使用Notification.Builder。

如何使用它?

当我尝试创建一个新的实例,它告诉我:

  Notification.Builder不能被解析为一个类型
 

解决方案

从http://developer.android.com/reference/android/app/Notification.Builder.html:这是API 11,因此,如果您正在开发的任何东西早于3.0,你应该继续使用旧的API。

更新:在NotificationCompat.Builder类已被添加到支持包,所以我们可以用它来支持API级别V4及以上:

http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html

人人都会设计模式 07 建造者模式 Builder

I found that I am using a deprecated method for noficitations (notification.setLatestEventInfo())

It says to use Notification.Builder.

How do I use it?

When I try to create a new instance, it tells me:

Notification.Builder cannot be resolved to a type

解决方案

From http://developer.android.com/reference/android/app/Notification.Builder.html: this is in API 11, so if you are developing for anything earlier than 3.0 you should continue to use the old API.

Update: the NotificationCompat.Builder class has been added to the Support Package so we can use this to support API level v4 and up:

http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html

阅读全文

相关推荐

最新文章