我正在使用Phonegap v1.3制作一个Phonegap Android 应用程序。我为 phonegap 编写了一个插件,它从系统中获取一个特定的文件,然后执行一个 js 函数。
由于所有插件都扩展了 Phonegap 类 Plugin,因此我无法直接从那里执行 js 函数。所以从插件的执行功能,我执行-->
PluginResult result = null;
Home home = new Home();
result = new PluginResult(Status.OK);
home.loadPage("pic.jpg");
在这个 Home 是我扩展Droidgap 的主要课程。
在家里我有功能loadPage
public void loadPage(String filePath){
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("javascript:navigator.somefunc(\""+filePath+"\");");
}
问题是 DroidGap 的setIntegerProperty函数正在抛出 NPE。这是日志。
01-16 11:41:32.364: W/System.err(13162): java.lang.NullPointerException
01-16 11:41:32.364: W/System.err(13162): at com.phonegap.DroidGap.setIntegerProperty(DroidGap.java:738)
01-16 11:41:32.364: W/System.err(13162): at e2o.mobile.Home.loadSharePage(Home.java:120)
01-16 11:41:32.364: W/System.err(13162): at com.phonegap.plugins.checkImage.CheckUploadImage.execute(CheckUploadImage.java:158)
01-16 11:41:32.364: W/System.err(13162): at com.phonegap.api.PluginManager$1.run(PluginManager.java:150)
01-16 11:41:32.364: W/System.err(13162): at java.lang.Thread.run(Thread.java:1019)
基本上在 setIntegerProperty 函数中 -
public void setIntegerProperty(String name, int value) {
this.getIntent().putExtra(name, value);
}
this.getIntent ()返回 null。你能告诉我我错过了什么吗?或者在我的用例场景中,我如何执行那个 js 函数。如果我不使用
super.setIntegerProperty("loadUrlTimeoutValue", 60000, intent);
然后 loadUrl 什么也不做。JS 没有被调用,或者超时。