As an alternative to my posted code, I tried as a test example instead InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); CheckBox c = new CheckBox(this); addContentView(c,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT)); imm.showSoftInput(c.getRootView(), InputMethodManager.SHOW_FORCED);
Again, I get the soft keyboard and associated proper key events with this code as I run my program. Moreover, even after launching a third-party activity via startActivityForResult() as described in my previous message I now get the soft keyboard popup, *BUT* it does not generate any key events that my app sees. The dummy checkbox shows up alright, but it is as if c.getRootView() somehow no longer belongs to my app despite it defining the checkbox. I should note that there seems to be a timing issue, in that the problem always occurs after running the third-party activity for only a few seconds, and the problem often does not occur if I let the third-party activity run a bit longer. Maybe the issue is in part that Android has not quite finished stopping my app before returning to it? Still, I cannot figure out how to properly fix this problem myself, or where to add semaphores for better stability. In all other respects my app runs fine after the third-party activity excursion, e.g., all other touch events on the screen continue to work fine. It is only the soft keyboard of InputMethodManager that is here causing me problems. Is it a known issue with InputMethodManager? I'm running Android 2.2 (Froyo) on HTC Desire. Thanks! On Thu, Dec 9, 2010 at 7:14 PM, blindfold <seeingwithso...@gmail.com> wrote: > I have a problem with the soft keyboard after launching another > activity. Upon a touch event I use > > InputMethodManager imm = (InputMethodManager) > getSystemService(INPUT_METHOD_SERVICE); > imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); > > to pop up the soft keyboard, which works just fine. > > However, after launching and returning from another (third-party) > activity via startActivityForResult(), the touch events again work > fine but the soft keyboard no longer shows up with the above lines. I > have this problem after launching the phone's browser, after launching > ZXing as well as after launching an Admob test ad. Apparently > something about the launched activity still lingers after returning > from these third-party activities. What must one do to restore a > proper state to get the soft keyboard to pop up again, or is this an > Android bug? > > Curiously, the problem is cured after doing yet another > startActivityForResult() but then for one of my own activities. The > question is what exactly it is that I need to "reset" to regain proper > toggleSoftInput() behavior. > > Thanks! > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en