android.js 780 B

12345678910111213141516171819202122232425262728
  1. var Context,
  2. InputMethodManager,
  3. main,
  4. imm;
  5. function initKeyboardAndroid(){
  6. if(plus.android.runtimeMainActivity){
  7. plus.android.importClass(plus.android.currentWebview());
  8. Context = plus.android.importClass("android.content.Context");
  9. InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
  10. main = plus.android.runtimeMainActivity();
  11. imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
  12. }
  13. }
  14. function openSoftKeyboard() {
  15. if(!plus.android.runtimeMainActivity) {
  16. plus.webview.currentWebview().nativeInstanceObject()
  17. .plusCallMethod({
  18. "setKeyboardDisplayRequiresUserAction": false
  19. });
  20. } else {
  21. plus.android.currentWebview().requestFocus();
  22. imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
  23. }
  24. }