Is it possible to popup virtual keyboard when some command is being received from server? I am trying to call focus on text area but soft keyboard is not coming. I agree that for keyboard to popup, user event is required. Is there any way to show virtual keyboard forcefully? I am talking about web app inside Android chrome browser.
You can do this by calling focus() then click() on the input, but, as you say, only when the script is initiated by user input. My current answer, having spent a day fiddling, is that there is no way to get around this.
This question may help you: Showing Android's soft keyboard when a field is .focus()'d using javascript
In your case you could try to have a hidden text input field on your page and trigger a click event on it when the command is received from the server.
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
May this will help you
Related
I am using flutter_inappwebview to open webview in flutter app.
My use case is, I want to open keyboard as soon as user enters in the webview. The page that I am loading in webview already has a focused input field but the keyboard does not open automatically.
I have to tap on the input field (in the page) in order to open the keyboard. If I load the same page on web-browser, it works fine and shows focused (with cursor) input field.
Some observation that I had - If I interact with web-view and come back to that page, keyboard opens up automatically. So it seems, we have to do some user interaction (real, not programatically) in order to focus element in page.
How to focus by default the webview to let me programmatically set the focus on a specific webview input? Or Is there any thing that can be done in web-page to open keyboard? Thanks in advance.
I have tried everything in web-page to open the keyboard like adding focus only when page is fully loaded. This was done in web-page, not from flutter side. But it does not open the keyboard, just leaves the input field in focused state (but cursor does not appear).
is there any way to set focus on the input field without showing keyboard on a device? The code is shared across the website and the mobile device. I just want to acquire situation when on a website I got "focus" on the input element as well as on device but without displaying a keyboard on the device. I tried:
document.getElementById("myInput").focus();
but doesn't work.
Why do you want to focus an input field if you don't want to write in it? Otherwise you can check with
var isMobile = Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if the user agent is mobil before you take the focus.
It's a normal behavior of device.
You can use some cordova plugin (like this cordova-plugin-keyboard) to hide the keyboard.
Don't forget to check out if the user agent is from a mobile device
Anyway, it's the behavior of device, hide the keyboard will make your application act different from the others
I have been working on this specific requirement for more than 2 months now. But I haven't found a solution yet to disable the native keyboard when an input field is focused in a webview. I am building an app which has a built in keypad(essentially a view) and I want this to be displayed instead of the native keyboard.
What I've tried so far:
Add javascript eventListener for click events to display my keypad
using JavscriptInterface.(Works)
Set the webview focusable:false and
its parent's descendantFocusability to blocksDescendants (This works
but doesn't display the cursor on the input field)
Hiding the native
keyboard on resize event of javascript using loadUrl method.(Works
but the native keyboard is displayed momentarily before hiding the
keyboard)
Listening to the OnGlobalLayoutChange event to check if
the keyboard has been added. (Works but the result is same as
in the case above with a little improve in performance)
Force stop the IME service. (Works but the app has to be a system
app to force stop packages and the keyboard service has to be started
whenever the app goes to background.
Is there a way in which I can make this work?
You should set the windowSoftInputMode to stateAlwaysHidden for the Activity containing the web view. This should keep the onscreen keyboard hidden for the entirety of that Activity.
Is there a way to prevent the on-screen keyboard from popping up by default when a HTML text input field gets focus on a windows 8 touch screen pc?
The application in question is a barcode/rfid scanning web application.
It would be preferable if the user could also still pop up the on-screen keyboard manually if they need it.
Preferably a solution which avoids changing the global settings of the machine.
More Info: The text input field needs to be able to receive focus and accept keyboard input from the bar-code and rfid scanners attached to the terminal.
Try
$("#textbox1").attr("readonly", "readonly");
or
$("#state").attr("readonly", true);
Thanks
AB
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.
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.
https://stackoverflow.com/a/1947370/1183256
Lastly (I'm not sure how much this would differentiate from the first one) you could create your own IME.
How to develop a soft keyboard for Android?
http://developer.android.com/guide/topics/text/creating-input-method.html