试图根据用户使用Cordova 2.2.0使用phonegap android设置的日期和时间发出警报或提醒,从这里下载phonegap localnotification插件: phonegap android localnotification plugin 我刚刚到达它的初始阶段并在这行文件中得到错误,名为:ALARMRECEIVER.JAVA:
// Construct the notification and notificationManager objects
final NotificationManager notificationMgr = (NotificationManager) systemService;
final Notification notification = new Notification(R.drawable.ic_launcher, tickerText,
System.currentTimeMillis());
final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.vibrate = new long[] { 0, 100, 200, 300 };
notification.setLatestEventInfo(context, notificationTitle, notificationSubText, contentIntent);
/*
* If you want all reminders to stay in the notification bar, you should
* generate a random ID. If you want do replace an existing
* notification, make sure the ID below matches the ID that you store in
* the alarm intent.
*/
notificationMgr.notify(notificationId, notification);
错误仅在此行:
final Notification notification = new Notification(R.drawable.ic_launcher, tickerText,
System.currentTimeMillis());
红色高亮显示我:
R cannot be resolved to a variable
仅因为单个错误无法运行此项目
答案 0 :(得分:0)
来自插件自述文件:
修复第67行中AlarmReceiver.java中的导入 R.drawable.ic_launcher被引用,因此它匹配您的图标 项目
确保/ res /文件夹中有一个名为ic_launcher的图标。然后还要检查/ res /文件夹中的任何文件中是否存在任何XML错误。 R类是从/ res /文件夹自动生成的,如果缺少某些内容,或者存在错误的XML等,则不会创建它,从而导致此错误。如果您仍然遇到错误,请尝试执行Make - > Clean。 StackOverflow还有一些关于缺少R文件或R未生成的问题。