Android 中相当新:)
我有一个通知生成器,如果应用程序目标版本 > 4.0,它可以正常工作
然而,当我切换到 2.3 时,我在这一行收到一条错误,提示“Notificaiton.Builder 无法解析为类型”。
Notification notification = new Notification.Builder(this)
.setSmallIcon(drawable_small)
.setLargeIcon(drawable_big)
.setWhen(System.currentTimeMillis()).setTicker(content_title)
.setContentTitle(content_title).setContentInfo(content_info)
.setContentText(content_text).setContentIntent(pIntent)
.getNotification();
这个问题现在已经解决了!
不过我现在又要一份了
它给我每个 R(资源)一个错误,我可以选择导入 R。
如果我导入它,它会在每个资源上给我错误。
setContentView(R.layout.activity_main);
实施您的Notification
like
Notification noti = new NotificationCompat.Builder(context)
.setSmallIcon(icon_small)
.setTicker(message)
.setLargeIcon(largeIcon)
.setWhen(System.currentTimeMillis())
.setContentTitle(title)
.setContentText(message)
.setContentIntent(contentIntent)
//At most three action buttons can be added
.setAutoCancel(true).build();
And add 支持库 v4到您的项目中并导入
import android.support.v4.app.NotificationCompat;
NotificationCompat
用于访问功能的帮助程序Notification
之后介绍API level 4
in a 向后兼容时尚.
欲了解更多信息,请访问:http://developer.android.com/guide/topics/ui/notifiers/notifications.html http://developer.android.com/guide/topics/ui/notifiers/notifications.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)