Android Keyboard do not open on focus in Edittext - android

There are lot of questions regarding android keyboard not opening ,when there is a focus on edittext.
And there are many ways also to open keyboard forcefully.However usually keyboard opens automatically on request focus. But in some cases it do not opens even there is a focus in edittext.
What usually happens behind that keyboard do not appears automatically as it usually does ?

For automatic keyboard, use the following
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
also this can help in manifest file :
<activity
android:name="com.example.activities.MyActivity"
android:configChanges="keyboard"
>
</activity>

Related

How to resolve view pushing problem of Android keyboard when clicking on EditText?

In my Android app, when a user clicks on EditText the keyboard appears and just pushes all the screen views upwards dislocating my UI components.
How can I solve this issue, I want the keyboard to overlay over my UI components and then the user can type what he/she wants.
Add this to the activity in your AndroidManifest.xml
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan"

how to set InputType to InputType.TYPE_CLASS_NUMBER in Android Version 7.0 (nougat) and above

I have created Custom Edittext in which i set the InputType as this.setInputType(InputType.TYPE_CLASS_NUMBER); but the problem is it working perfectly on below 7.0(nougat) but above 7.0 it show me alphanumeric keyboard.
one another weird thing happen is when I touch the EditText, I quickly get the soft numerical keyboard, but in less than a second it automatically changes to regular soft keyboard showing all letters. also when keyboard is open, than ill press back button, than keyboard close, but when i re-enter in Edittext. keyboard is not open until i click on onther edittext then current edittext
Is this issue in Nougat or I am doing something wrong
For information i have used code to setSoftInputMode to ADJUST PAN
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
|WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
and to set Numeric keypad use this.setInputType(InputType.TYPE_CLASS_NUMBER);
Edited -
when i remove -
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
|WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
from activity every thing work fine( number keypad open at number edittext , alphanumerical keypad open at alphanumerical edittext ) except the content not goes up-direction means keypad hide edittext(because ignorance of this property SOFT_INPUT_ADJUST_PAN)
Help appreciated thanks
I tried to use setInputType(InputType.TYPE_CLASS_NUMBER) on devices 7+ and didn't see the behaviour that you described. Looking for another thread, runnable or any callback which changing InputType of your EditText after opening or simultaneously.
Try setting softInputMode in your Manifest file, it might give you your desired behavior.
<activity
android:name=".YourActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />

Stop showing softkeyboard in WebView

Is there a way to prevent the softkeyboard to show up in a WebView? My app is attached to a scanner which simulates keyboard entry (that works so far), so the softkeyboard is only annoying when it occupies the screen.
The Nullkeyboard from the Playstore does the trick, but in certain cases I would like to enable the keyboard again.
If it helps, I can control the content of the webpage being shown. Would like to avoid programming a full input method.
In your manifest, on the activity, use android:windowSoftInputMode="stateAlwaysHidden" and the soft keyboard should never be displayed.

Why does soft keyboard show up?

Is there any way to find out why the soft keyboard show up in one of my views ?
The app is quite big and it's not obvious why the keyboard gets enabled. Do you know any way to debug that?
You can use the following line of code in the activity's onCreate method to make sure the keyboard only pops up when a user clicks into an EditText
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
or
android:windowSoftInputMode="stateHidden"
In the manifest.

Android default onfocus on autofocus and editview,How to remove that?

In my application I have a autocomplete in first activity and some edittext in second activity.
When I run my code in emulator it works fine and I am not seeing any virtual keyboard on screen when program is excecuted.
But when I deploy it in device when the application loads, onfocus is directly on autocomplete and a keyboard pops out, and also when I navigate from first activity to second activity onfocus is on first edittext and keyboard pops out.
I want to disable this onfocus on all the page. how to do that ?
Take a look at this question:
Stop EditText from gaining focus at Activity startup?
That worked for me... I just put this line in the activity definition on Manifest.
<activity
...
android:windowSoftInputMode="stateHidden" >
</activity>

Categories

Resources