问题描述
pretty在android的新位置:)
我有一个通知,其中建设者没有问题的工作,如果该应用程序的目标版本> 4.0
然而,当我切换到2.3我在这一行它说Notificaiton.Builder不能被解析为一个类型得到一个错误。
的通知的通知=新Notification.Builder(本)
.setSmallIcon(drawable_small)
.setLargeIcon(drawable_big)
.setWhen(System.currentTimeMillis的())。setTicker(content_title)
.setContentTitle(content_title).setContentInfo(content_info)
.setContentText(content_text).setContentIntent(pIntent)
。得到通知();
此问题现在已经解决了!
但是我真的现在不得不另外一个
它给了我一个错误的每个R(资源),我可以选择导入R.
如果我导入它,它给我的错误上的每个资源。
的setContentView(R.layout.activity_main);
实施你的通知
像
通知NotI位=新NotificationCompat.Builder(上下文)
.setSmallIcon(icon_small)
.setTicker(消息)
.setLargeIcon(largeIcon)
.setWhen(System.currentTimeMillis的())
.setContentTitle(职称)
.setContentText(消息)
.setContentIntent(contentIntent)
//最多三个动作按钮可以添加
.setAutoCancel(真).build();
和增加支持库V4 到你的项目,也导入
进口android.support.v4.app.NotificationCompat;
NotificationCompat
帮手在通知
在 API级别4 $出台访问功能C $ C>在向后兼容的方式即可。
有关更多信息,请访问:
Pretty new in android here :)
I have a notification builder which works with no problem if the application target version is > 4.0However when I switch to 2.3 I get an error on this line which says "Notificaiton.Builder cannot be resolved to a type".
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();
This problem is now solved!However I`m having another one nowIt gives me an error on every R (resource) and I have the option to Import R.If I import it,its giving me errors on every resource.
setContentView(R.layout.activity_main);
Implement your 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 support library v4 into your project and also import
import android.support.v4.app.NotificationCompat;
NotificationCompat
helper for accessing features in Notification
introduced after API level 4
in a backwards compatible fashion.
For more information go to:http://developer.android.com/guide/topics/ui/notifiers/notifications.html
这篇关于通知生成器中的Android 2.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!