建立通知时发生错误 [英] error when building a notification
问题描述
我正在使用本教程 http://www.vogella.com/articles/AndroidNotifications/article.html ,我想构建通知
I am using this tutorial http://www.vogella.com/articles/AndroidNotifications/article.html , I want to build notification
//准备意图,如果 //已选择通知
// Prepare intent which is triggered if the // notification is selected
Intent intent = new Intent(this, NotificationReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// Build notification
// Actions are just fake
Notification noti = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject")
.setSmallIcon(R.drawable.icon)
.setContentIntent(pIntent)
.addAction(R.drawable.icon, "Call", pIntent)
.addAction(R.drawable.icon, "More", pIntent)
.addAction(R.drawable.icon, "And more", pIntent).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
我在addAction
行中出错,eclipse说the method addaction(ing, String pendingintent) is undefined for the type notification.builder
I have error in the line addAction
, eclipse says that the method addaction(ing, String pendingintent) is undefined for the type notification.builder
推荐答案
您正在使用错误版本的支持库. AddAction已在r13(可能更早)中引入.
You are using a bad version of the support library. AddAction has been introduced in r13 (maybe earlier).
这篇关于建立通知时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!