Android Keyboard automatically appears for EditText when activity is created - android

I have a single activity class and it has a two EditTexts on the screen. When the activity launches the keyboard launches with it. Why is this? I did not request enter anything yet into the edit box. Why does it do this? And how can I get rid of this behavior?

Try setting your stateHidden in the manifest file for the activity:
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
and this might be helpful:
How to keep soft keyboard from opening on activity launch in Android?

Related

Keyboard not showing on activity start: Android phones

I have an edittext in my activity, and on activity and on create view
I am setting the focus on the activity. while setting focus, I am also
trying to show the keyboard. It works on some devices, but on others it
just doesn't show.
I tried to step through the code and found that the view is not created, when
the show keyboard is called. Maybe that is the reason.
I am not sure what the problem is. Is there a way to make sure, that if a edit text
is in focus, the keyboard shows up on app start.
Thanks,
You can try to show the Soft Keyboard by calling the following line during onCreate:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
I hope that helps.
In your AndroidManifest.xml, add this attribute to the <activity> tag for the Activity you want the keyboard shown:
android:windowSoftInputMode="stateVisible"

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.

EditText has focus when Activity starts, but soft keyboard is not shown

as mentioned above, the keyboard does not show up, although the EditText is focused (orange border) and the cursor is blinking.
When I click into text field, it opens up, however I want it to be open right when the activity starts.
I tried setting android:windowSoftInputMode="stateVisible" in the activity, I tried showSoftInput(yourTextBox, InputMethodManager.SHOW_IMPLICIT); and also requestFocus().
But no success...
What could be the problem?
Try something like this:
EditText myEditText = (EditText) findViewById(R.id.editPasswd);
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(myEditText, InputMethodManager.SHOW_FORCED);
Are you testing on emulator? If you do, you should know that keyboard doesn't pop up on emulator :), but it does on a real device
Good luck,
Arkde
Another way to show the keyboard when the Activity is created is to add this code in your AndroidManifest file for the activity which you want to show the keyboard on starts :
<activity android:name=".UserLogin" android:windowSoftInputMode="stateAlwaysVisible"/>

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>

Supress the Soft Keboard when an activity loads... yet again

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Same problem that I've read on other posts. I don't want the soft keyboard to pop up when the Activity loads. The above code snippet works, however my View no longer scrolls up so that the User can still see the EditText.
It scrolls without this line of code. Any ideas?
Set right attribute on your activity in manifest
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

Categories

Resources