
Notification.Builder builder = new Notification.Builder(this);builder.setContentIntent(contentIntent) .setSmallicon(R.drawable.ic_launcher) .setTicker(notificationMessage) .setWhen(System.currentTimeMillis()) .setautoCancel(true) .setContentTitle(newNotificationsCount + " New Notifications") .setContentText(notificationMessage);Notification notification = builder.getNotification();nm.notify(R.string.app_name,notification);
这给出了错误:
调用需要API级别11(当前最小值为10):androID.app.Notification $Builder #setContentIntent
我下载了androID.support.v4.jar将它添加到与src和res等目录相同的libs文件夹中.
右键单击项目资源管理器中的jar并添加到构建路径.
我的应用程序有一个最小API = 10和目标API = 15
谢谢
解决方法@H_404_24@ Notification的支持类似乎有一个不同的名称,NotificationCompat.对于您的API 10代码,您需要使用: NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
并将您的import语句更改为:
import androID.support.v4.app.NotificationCompat.Builder;总结
以上是内存溢出为你收集整理的android – API 10中的Notifications.Builder全部内容,希望文章能够帮你解决android – API 10中的Notifications.Builder所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)