【发布时间】:2013-03-12 04:00:20
【问题描述】:
我正在使用以下代码在我的 BroadcastReceiver 的 onRecieve 方法内创建一个通知,但它给了我以下异常:
java.lang.IllegalArgumentException: contentIntent required
代码:
NotificationManager notificationManager;
notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
String tickerText;
String expandedText;
String expandedTitle;
int icon;
long when;
Notification notification;
int notificationref = new Random().nextInt(100) + 1;
icon = R.drawable.reminder;
tickerText = "New Reminder";
when = System.currentTimeMillis();
notification = new Notification(icon, tickerText, when);
expandedText = "Reminder at: "
+ DateOrTimeString.getTimeString(task.time) + "\n"
+ task.detail;
expandedTitle = "Reminder:" + task.topic;
Intent intentDestroyer = new Intent(context, RemindHomeActivity.class);
intentDestroyer.putExtra("ID", task.id);
intentDestroyer.putExtra("NOTIFICATIONREF", notificationref);
launchIntent = PendingIntent.getActivity(context, notificationref,
intentDestroyer, 0);
notification.setLatestEventInfo(mContext, expandedTitle, expandedText,
null);
notificationManager.notify(1, notification);
此问题仅在 API 级别低于 11 时出现。它在 API 级别 15 Icecream Sandwitch 中起作用
【问题讨论】:
-
请完整的堆栈跟踪,源代码中有错误行
-
和其他异常一样,在DDMS中不显示异常的行号
标签: android exception android-notifications