java – android 2.3中的Notifications Builder

这里的android很新:)

如果应用程序目标版本是>我有一个通知构建器,没有问题. 4
但是,当我切换到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 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();

并将支持库v4添加到项目中并导入

import android.support.v4.app.NotificationCompat;

NotificationCompat帮助程序,用于以向后兼容的方式访问API级别4之后引入的Notification中的功能.

有关更多信息,请访问:http://developer.android.com/guide/topics/ui/notifiers/notifications.html

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...