Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4064014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:48:02+00:00 2026-05-20T15:48:02+00:00

I am showing a dialog for textinput and would like to automatically display the

  • 0

I am showing a dialog for textinput and would like to automatically display the soft keyboard if no hard keyboard is open. In order to get it to display on my Samsung Galaxy Tab, I had to use the SHOW_FORCED flag, the SHOW_IMPLICIT flag did not work. Also, on dialog dismissal I would like to close the keyboard if I forced its display. However, the code I’m using below does not close the keyboard on my Galaxy Tab; I assume it is because I used the Explicit flag to show.

    /* from the dialog constructor*/

    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.restartInput(mEditText);

    //only display if there is no hard keyboard out 
    Configuration config = getResources().getConfiguration();
    if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
    {
      mForcedKeyboardDisplay = true;
      imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    }


    /* from the onDismiss() method*/

    //if we previously forced keyboard display, force it to close
    if (mForcedKeyboardDisplay)
    {
       InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
       imm.restartInput(mEditText);

       imm.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
       //this doesn't work either 
       //imm.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
       //nor does this
       //imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:48:03+00:00Added an answer on May 20, 2026 at 3:48 pm

    First, don’t use toggleSoftInput(). That does what it name says — toggles the state of the IME. If you actually want it make sure it is shown, use showSoftInputFromWindow().

    Second, there is no reason to call restartInput().

    Calling showSoftInput() with a 0 flag is exactly what the framework does when you tap on a text view to show the IME. In fact here is the code: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/TextView.java

    If you can get the IME to be shown by tapping on the text view, but your own call is not working, you really need to figure out why your call is not working. I would strongly recommend NOT using SHOW_FORCED — that has somewhat special behavior, which I doubt you want. (For example if the user presses home the IME will stay open. Generally not desirable.)

    The most likely reason for your call to hide the IME to not work is that your window doesn’t have input focus at that point… you will probably see a message in the log if this is the case. In fact, be sure to look in the log anyway since often messages are printed when problems happen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I go about showing an open file (or file select) dialog in
Currently i am showing fbml.dialog like this : FB.ui( { 'method': 'fbml.dialog', 'display': 'dialog',
I would like to trigger showing a dialog X seconds after something happens in
Is there a way to start off showing a dialog modally, but then instead
My dropdown boxes are showing through a jquery modal popup dialog, how do I
I am showing a custom dialog in my application, which stays for a small
I have a modal dialog showing up and the user can make some changes
i want to display a dialog in my android application where certain TextViews in
in my app when i click a button showing a dialog box with listview.
In my application, when i am clicking i showing a dialog. and when i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.