diff --git a/src/android/Keyboard.java b/src/android/Keyboard.java index 7d503b3..1948d0b 100644 --- a/src/android/Keyboard.java +++ b/src/android/Keyboard.java @@ -3,6 +3,7 @@ import android.app.Activity; import android.content.Context; import android.view.inputmethod.InputMethodManager; +import android.view.View; import org.apache.cordova.*; import org.json.JSONArray; import org.json.JSONException; @@ -13,14 +14,22 @@ public class Keyboard extends CordovaPlugin { public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { Activity activity = this.cordova.getActivity(); InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE); - + + View view; + try { + view = (View)webView.getClass().getMethod("getView").invoke(webView); + } + catch (Exception e){ + view = (View)webView; + } + if("show".equals(action)){ - imm.showSoftInput(webView.getView(), 0); + imm.showSoftInput(view, 0); callbackContext.success(); return true; } else if("hide".equals(action)){ - imm.hideSoftInputFromWindow(webView.getView().getWindowToken(), 0); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); callbackContext.success(); return true; }