我可以从我的phonegap java脚本函数和android 2.2中使用java函数,但是相同的代码没有在API 17上运行。我应该怎么做才能从API 17中的java脚本调用本机java代码。
我在我的java文件中使用这个代码
objCustomNativeAccess = new CustomNativeAccess(this, appView);
appView.addJavascriptInterface(objCustomNativeAccess,
"CustomNativeAccess");
super.loadUrl("file:///android_asset/www/index.html");
我的 CustomNativeAccess 课程是
public class CustomNativeAccess {
private WebView mAppView;
private DroidGap mGap;
/**
* Constructor
*
* @param gap
* @param view
*/
public CustomNativeAccess(DroidGap gap, WebView view) {
mAppView = view;
mGap = gap;
}
/**
* Get the device phone number
*
* @return
*/
public JSONObject login(String email, String password) {
JSONObject object = new JSONObject();
object.put("Login_Status", login_status);
object.put("date", dateString);
return object;
}
在我的java脚本中,我使用这一行来调用这个登录函数
var value = window.CustomNativeAccess.login(email,pass);
所以使用这个我成功地在 api 2.2 上调用它但是当我在 api 17 上运行这个代码时它给了我错误
未捕获的类型错误:对象 [object Object] 在 file:///android_asset/www/index.html:81 处没有方法“登录”
我如何在 api 17 上使用它