简体   繁体   English

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

[英]Phonegap Local Notification Plugin for Android

I'm working on a "Reminders" application on Android using Phonegap[Cordova 2.2]. 我正在使用Phonegap [Cordova 2.2]在Android上开发“提醒”应用程序。

The user enters a specific date for his reminder and I'm supposed to notify him on time. 用户输入其提醒的特定日期,我应该按时通知他。

I used this plugin to Just show a notification in the status bar & they are working fine. 我使用此插件只是在状态栏中显示通知,并且它们工作正常。

But I want the notifications to show at specific times. 但是我希望这些通知在特定时间显示。 Is there some method to do it ? 有一些方法可以做到吗?

I found this plugin that's supposed to do what I want but it's not working, it shows errors at : 我发现该插件可以执行我想要的操作,但不起作用,它在以下位置显示错误:

import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;

The import com.phonegap.api.Plugin cannot be resolved 导入com.phonegap.api.Plugin无法解析

So, how can I fix this error ? 那么,如何解决此错误? I know it might be easy, but I never made native Android Apps before so I'm kind of confused. 我知道这可能很容易,但是我之前从未制作过本机Android应用程序,因此感到有点困惑。

Thanks 谢谢

Looks like a difference between 2.0.0 and 2.2.0, and like the plugin needs updating. 看起来2.0.0和2.2.0之间有区别,并且插件需要更新。

import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;

This should give you a jumping off point: http://docs.phonegap.com/en/2.2.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android 这应该给您一个起点: http : //docs.phonegap.com/en/2.2.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android

For the new Phonegap Release you must also change some stuff: 对于新的Phonegap版本,您还必须更改一些内容:

  1. The LocalNotification class must "extends CordovaPlugin" now LocalNotification类现在必须“扩展CordovaPlugin”
  2. Import classes like eomer says 像eomer这样的导入类说
  3. The execute method of LocalNotification.java must return a boolean now LocalNotification.java的execute方法必须立即返回一个布尔值
  4. Change all return arguments that are affected (from PluginResult) to boolean of your choice 将所有受影响的返回参数(从PluginResult)更改为您选择的布尔值
  5. Get the context in a new way ctx = this.cordova.getActivity(); 以新方式获取上下文ctx = this.cordova.getActivity(); and give it the ...AlarmHelper(ctx) 并给它... AlarmHelper(ctx)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM