12

I am using phonegap to develop a web app for Android, and since I will have my own keypad in HTML, I need to disable android's system keyboard, preventing the it from showing up when the user clicks on any text input field. I don't want to use readonly input field or onblur() since I would like to have the cursor in the text filed so user can move the cursor position while they're entering inputs.

So I want to completely disable Android's keyboard on default, I tried adding android:windowSoftInputMode="stateAlwaysHidden" to manifest.xml but this does not work.

I also try use a javascript interface from here, but there was a javascript-java bridge crash issue on Android 2.3.x.(link to issue). So I still don't have a good solution now. Please help.

Thank in advance for any help.

starscream_disco_party
  • 2,816
  • 5
  • 26
  • 42
kli
  • 283
  • 1
  • 5
  • 16
  • Have you configured the `WebView`'s `WebViewClient` and `WebChromeClient`? I worked on a project that used jQuery Mobile and we had to configure both of those for things to work properly. You may have to intercept a JS event and tie that into the Java logic in the native code. I'll look into this and keep you updated. – starscream_disco_party Jul 23 '12 at 05:59
  • Thanks for the tips, but I think phonegap already configured both webviewclient and webchromeclient. I will look more into it. thanks – kli Jul 23 '12 at 17:58
  • 1
    Okay, look into my suggestions below. It doesn't look like there's a pretty way to do this, but then again doing anything prettily in Android is near impossible in a lot of cases. – starscream_disco_party Jul 23 '12 at 22:15

1 Answers1

1

Okay, you've got a few options! You can try to disable the keyboard completely using:

  • getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    • If you choose this way, be sure to return the settings to normal if that's not done automatically. I haven't used this before and couldn't tell you how it behaves, but keep that in mind! You don't want a user to reply to a text they receive while using your app only to have their keyboard disabled :)


  • You could use something similar to the following link. I haven't dug through it very thoroughly (tl;dr) but he creates a custom view that extends from android.inputmethodservice.KeyboardView and uses that instead.


Community
  • 1
  • 1
starscream_disco_party
  • 2,816
  • 5
  • 26
  • 42