本地通知 Android

Posted

技术标签:

【中文标题】本地通知 Android【英文标题】:LocalNotification Android 【发布时间】:2013-03-14 20:32:39 【问题描述】:

我正在尝试为我的 Phonegap 应用程序使用 LocalNotification 插件。 https://github.com/phonegap/phonegap-plugins/tree/master/android/LocalNotification

在完成所有步骤之后.. 我在 Localnotification.java 中遇到了很多错误.. 其余的工作正常。

有什么问题?它已经从第一句话开始:

前两个错误: 导入 com.phonegap.api.Plugin; 导入 com.phonegap.api.PluginResult;

第三个错误: 公共类 LocalNotification 扩展插件

我只是一个初学者..但也许有人可以帮助...?我错过了一个步骤,还是错过了一些必需的文件?

使用 Eclipse,最新的 cordova/phonegap。

【问题讨论】:

【参考方案1】:

在这里看到同样的问题:p

似乎在这里使用相同的设置,即带有最新的 Cordova 和 phonegap 的 Eclipse。刷新插件后,Eclipse 显示 30 个错误、1 个警告、0 个其他错误。 AlarmReceiver.java 中有 1 个警告和 1 个错误,其余错误在 LocalNotification.java 中。按照https://github.com/phonegap/phonegap-plugins/tree/master/Android/LocalNotification 的说明进行操作。

“问题”是:

Description Resource Path Location Type
The import com.phonegap.api cannot be resolved LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 12 Java Problem
The import com.phonegap.api cannot be resolved LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 13 Java Problem
ctx cannot be resolved or is not a field LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 35 Java Problem
The method execute(String, JSONArray, String) of type LocalNotification must override or implement a supertype method LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 34 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 34 Java Problem
Plugin cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 23 Java Problem
The method cancelAllNotifications() from the type LocalNotification refers to the missing type PluginResult LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 60 Java Problem
The method cancelNotification(String) from the type LocalNotification refers to the missing type PluginResult LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 57 Java Problem
The method add(boolean, String, String, String, String, Calendar) from the type LocalNotification refers to the missing type PluginResult LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 54 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 38 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 95 Java Problem
PluginResult cannot be resolved to a variable LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 93 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 93 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 83 Java Problem
PluginResult cannot be resolved to a variable LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 111 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 111 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 106 Java Problem
PluginResult cannot be resolved to a variable LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 95 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 132 Java Problem
PluginResult cannot be resolved to a variable LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 132 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 134 Java Problem
PluginResult cannot be resolved to a variable LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 134 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 113 Java Problem
PluginResult cannot be resolved to a variable LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 113 Java Problem
PluginResult cannot be resolved to a type LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 120 Java Problem
ctx cannot be resolved or is not a field LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 128 Java Problem
ctx cannot be resolved or is not a field LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 151 Java Problem
ctx cannot be resolved or is not a field LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 167 Java Problem
ctx cannot be resolved or is not a field LocalNotification.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 180 Java Problem
The method setLatestEventInfo(Context, CharSequence, CharSequence, PendingIntent) from the type Notification is deprecated AlarmReceiver.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 77 Java Problem
R cannot be resolved to a variable AlarmReceiver.java / application_title_mobile/src/com/phonegap/plugin/localnotification line 72 Java Problem

编辑:刚刚在 github 上发布了一个问题:https://github.com/phonegap/phonegap-plugins/issues/1076

【讨论】:

【参考方案2】:

我更新了localNotification插件以支持最新的phonegap,也许你想试试https://github.com/zhuochun/local-notification

【讨论】:

以上是关于本地通知 Android的主要内容,如果未能解决你的问题,请参考以下文章

使用 Cordova 的 Android 本地通知插件

本地通知未在 Android 10 中触发

清除 Android 的本地通知 cordova 插件

本地通知崩溃应用程序android java

适用于 Android 的 Phonegap 本地通知插件

来自后台的Android本地通知没有标题