如何准确使用 Notification.Builder [英] How exactly to use Notification.Builder

查看:21
本文介绍了如何准确使用 Notification.Builder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现我使用了一种不推荐使用的通知方法 (notification.setLatestEventInfo())

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

它说使用 Notification.Builder.

It says to use Notification.Builder.

  • 我如何使用它?

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

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

Notification.Builder cannot be resolved to a type

推荐答案

这是在 API 11 中,所以如果你正在为 3.0 之前的任何东西进行开发,你应该继续使用旧的 API.

This is in API 11, so if you are developing for anything earlier than 3.0 you should continue to use the old API.

更新:NotificationCompat.Builder 类已添加到支持包中,因此我们可以使用它来支持 API 级别 v4 及更高版本:

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/参考/android/support/v4/app/NotificationCompat.Builder.html

这篇关于如何准确使用 Notification.Builder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆