的NoSuchMethodError Notification.Builder.build() [英] NoSuchMethodError Notification.Builder.build()

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

问题描述

   Notification noti = new Notification.Builder(context)
            .setContentTitle("TITLE").setContentInfo("INFO")
            .build();
notificationManager.notify(ID,noti);

我有该样品是从谷歌网页的问题。我有例外的NoSuchMethodError我不知道是怎么回事,所以我用老德precated法通知noti.setLatestEventInfo但我敢肯定有另一种解决方案。任何想法?

I have problem with that sample it is from google page. And I have exception NoSuchMethodError i don't know what's going on so I use old deprecated method with notifications noti.setLatestEventInfo but I'm sure there is another solution. Any ideas?

推荐答案

Notification.Builder.build()是API级别16。

在4.0.4,你应该使用<一个href=\"http://developer.android.com/reference/android/app/Notification.Builder.html#getNotification()\"相对=nofollow>的GetNotification()。

In 4.0.4,you should use getNotification().

或者你有更好的使用 NotificationCompat

这篇关于的NoSuchMethodError Notification.Builder.build()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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