Is it possible to open keyboard on Android without click or touch event? For example just after appending textarea to some element? element.focus() works for me on iOS but not on Android.
-
2@Vixed you should edit the question to make it fit better your own issue. As-is it is unclear whether it is for an Android native app in Java (as the current answer assumes), or for an hybrid app in JavaScript, e.g. using Cordova. – ghybs Oct 27 '17 at 08:04
-
Please clarify does your app is in java or an hybrid app. – Jaiprakash Soni Oct 27 '17 at 11:09
-
Webview javascript (jQuery) @ghybs – Vixed Oct 27 '17 at 14:57
-
check this https://stackoverflow.com/questions/9703271/force-keyboard-open-on-android – Jaiprakash Soni Oct 30 '17 at 04:54
4 Answers
Simply add "requestFocus" to your XML. Something like
<EditText
android:id="@+id/editText"
... />
<requestFocus />
and in onCreate()
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
Or: It could be just
editText.requestFocus();
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

- 125
- 2
- 13
This answer is based on the following assumption: You are using a WebView in your android app to insert a custom Javascript to achieve a certain task
Firstly create a method in your Android java class that will do do the job of popping up the keyboard:
@JavascriptInterface
public void takeUserInput() {
mWebView.setFocusable(true);
mWebView.setFocusableInTouchMode(true);
}
In your Javascript make a call to the takeUserInput()
method whenever you want to pop-up the keyboard.
You can read up on how to call android functions from Javascript.
Hope this helps!

- 281
- 1
- 3
- 10
You have to make sure that the window's soft input mode is set to "always visible" before requesting focus on your element. You can set it using:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
After that you can bring up the keyboard by requesting focus on your element:
element.requestFocus();

- 1
- 1
According to my Knowledge you can't open the keyboard without using a input. Try to use virtual keyboard read following.

- 7,237
- 4
- 28
- 34