1

First of all, I am aware of about 1000 other questions regarding the android keyboard... I am aware I can manually hide keyboard from window or control, and pass in any number of flags that are supposed to control where and when keyboard pops up.

Basically, I aim to have PREDICTABLE keyboard handling in my app... that is that unless explicitly told to focus this control, and popup keyboard, it'll only pop up when a user taps a text edit.

This app is extensive, and manually attempting to hide keyboard from even just the focused control (vs explicitly hiding each and every edit field).

I am also aware I can avoid the popup up keyboard when you dont want it there, by setting focus on a non text editable field, however, that seems like more of a hack than anything else.

So my question is... is there a way to just force app to never auto pop up keyboard on new dialogs, fragments etc... app wide? If I want this text field to et focus on new dialog, I'll manually handle those cases. In addition, any way to automatically handle keyboard dissapear when the previously focused control dissapears?

I just dont get logic there... if I step back and think about this, I'd only want keyboard popping up if I wanted to go type something. As far as keyboard popping up immediately when new dialog opens... seems like the exceptional case (there may be a couple times I'd want to do that).

I dont mind building a manager or something that keeps track of the state of keyboard, however i dont know if I can get at the information I'd need to make it work in a remotely intuitive manner, efficiently.

Any pointers or ideas would be greatly appreciated... because I am at my whits end with this... and I can assure you I've spent a good deal of time researching this and attempting fixes.

Note: Sorry about the title or hostility... I've fought this for quite some time, and been generally infuriated with how bizarre dealing with the keyboard can be.

Ronnyek
  • 482
  • 5
  • 16
  • I'm a little confused by your request. Your quote here `I am also aware I can avoid the popup up keyboard when you dont want it there, by setting focus on a non text editable field` suggests that it **is** predictable and that when you click outside the edittext, it goes away as intended. If you could post some code, especially where you are opening up dialogs or fragments, that would be great. Are you by any chance auto focusing on edit text boxes hence the "auto popup?" – Otra Jul 28 '11 at 16:46
  • Thats predictable... but my point is, I dont want the keyboard to pop when a textedit gets focused... I want it to pop when a user clicks. Text fields often get auto focused if they are part of a newly opened dialog etc. – Ronnyek Jul 28 '11 at 16:52

2 Answers2

0

So my question is... is there a way to just force app to never auto pop up keyboard on new dialogs, fragments etc... app wide?

No.

But you can use:

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

On each activity.

citizen conn
  • 15,300
  • 3
  • 58
  • 80
  • 1
    You should also be able to set that via a theme, since it shows up in `R.styleable`. – CommonsWare Jul 28 '11 at 17:22
  • any idea why tab control on a view with that setSoftInputMode would ignore that? I know the tab control effectively toggles visibility, but if parent window is told to always hide... I would expect the keyboard to stay gone =( – Ronnyek Jul 28 '11 at 17:59
0

Ok, I think I get what you're asking. Have a look at the second answer here:

Stop EditText from gaining focus at Activity startup

You can specify in your AndroidManifest.xml whether or not the softkeyboard should be hidden by adding this android:windowSoftInputMode="stateHidden" to the beginning of your activities tag (<activity>)

Community
  • 1
  • 1
Otra
  • 8,108
  • 3
  • 34
  • 49
  • well I didnt know about this... and this helps... except my app is heavily based on fragments... and very few activities. Still valuable though – Ronnyek Jul 28 '11 at 18:02