soft keyboard not appearing

I have a following dialog:

import android.app.AlertDialog;

public class IpDiscoveryDialog extends AlertDialog implements View.OnClickListener {

    private View view;
    private Context context;
    private Activity activity;

    private EditText ipEditText;


    protected IpDiscoveryDialog(Context context) {
        super(context);
        this.context = context;
    }

    public IpDiscoveryDialog(Context context, Activity activity) {
        this(context);
        this.activity = activity;
    }

    @Override
    public void setContentView(int layoutResID) {
        View view = getLayoutInflater().inflate(layoutResID, null);
        this.view = view;
        this.setContentView(view);
    }

    @Override
    public void setContentView(@NonNull View view) {
        super.setContentView(view);
        this.buildView(view);
        this.setCancelable(false);
    }

    private void buildView(View view) {
        view.findViewById(R.id.ipConfirmButton).setOnClickListener(this);
        this.ipEditText = view.findViewById(R.id.ipEditText);
    }
}

I open it from a different activity like this:

IpDiscoveryDialog ipDiscoveryDialog = new IpDiscoveryDialog(ScanDevicesActivity.this, ScanDevicesActivity.this);
ipDiscoveryDialog.create();
ipDiscoveryDialog.setContentView(R.layout.ip_discovery_dialog);
ipDiscoveryDialog.show();

And the layout of the dialog is the following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="10dp">

    <TextView
        android:id="@+id/textView8"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/set_ip_address"
        android:textAlignment="center"
        android:textColor="@android:color/black"
        android:textSize="24sp" />

    <EditText
        android:id="@+id/ipEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="@string/ip_address"
        android:importantForAutofill="no"
        android:inputType="text" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/ipConfirmButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/confirm" />
</LinearLayout>

The problem I have is that no matter what I do, I cannot open soft keyboard to edit that EditText. I tried open it manually in code, I tried different settings, nothing works.

Code like this does not work:

InputMethodManager mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);  
mImm.showSoftInput(SearchEdit, InputMethodManager.SHOW_IMPLICIT);

What else can I try? What is the issue here?


Try this class

public class IpDiscoveryDialog extends AlertDialog implements View.OnClickListener {

private View view;
private Context context;
private Activity activity;

private EditText ipEditText;


protected IpDiscoveryDialog(Context context) {
    super(context);
    this.context = context;
}

public IpDiscoveryDialog(Context context, Activity activity) {
    this(context);
    this.activity = activity;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.ip_discovery_dialog);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    buildView();
    this.setCancelable(false);
}

private void buildView() {
    findViewById(R.id.ipConfirmButton).setOnClickListener(this);
    this.ipEditText = findViewById(R.id.ipEditText);
}

@Override
public void onClick(View v) {

}
}

Soft keyboard doesn't appear, Add a requestfocus. In xml: <EditText> <requestFocus /> </EditText>. Programmatically edittext.requestFocus();. To "force" the SoftKeyboard to� Touch keyboard not appearing in Windows 10 Wondering if someone can help resolve a problem that's just developed with my tablet. The tablet, a Toshiba Encore running Windows 10, was working flawlessly until one day recently when I noticed the touch keyboard would no longer appear when I clicked fields in applications such as Chrome in tablet mode.


try adding below code in menifext file -

 <application
    .....
    android:hardwareAccelerated="true">

Hope this will help you.

Working with the Soft Keyboard, Displaying the Soft Keyboard. AVD Manager. By default, the soft keyboard may not appear on the emulator. If you want to test with the soft keyboard, be� mtga surface keyboard not appear surface keyboard does not appear surface no on screen keyboard surface not showing keyboard surface pro keyboard not appearing surface pro on screen keyboard not showing surface pro onscreen keyboard not working windows surface-on-screen keyboard-does-not-appear


Try this

    ipDiscoveryDialog .setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {

            ((InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
        }
    });

Solved: Soft keyboard not automatically coming up on Galax , Solved: Hello! I have recent reports from a few users who have Galaxy S9's with my Android AIR app (SDK 31.0) that the soft keyboard is not showing up when� The on-screen keyboard doesn't appear when I try to use the text input box or press the enter button on the TV remote How to exit Voice Search function in order to use the on-screen keyboard of the Android TV.


Have you tried to post showSoftInput? I use a utility function for this:

public static void showSoftKeyboard(EditText v) {
    Context c = v.getContext();
    InputMethodManager keyboard = (InputMethodManager)
            c.getSystemService(Context.INPUT_METHOD_SERVICE);
    v.requestFocus();
    keyboard.showSoftInput(v, 0);
}

public static boolean postShowSoftKeyboard(final EditText v) {
    return v.post(new Runnable() {
        @Override
        public void run() {
            showSoftKeyboard(v);
        }
    });
}

FIX: On-Screen Keyboard not working in Windows 10, On screen keyboard not appearing Windows 10 – This is one of the most using a third-party virtual keyboard software as a replacement. From there, click “Use the computer without a mouse or keyboard.” Uncheck the “Use On-Screen Keyboard” checkbox. If it’s already unchecked, check it, click Apply, then uncheck it–just for good measure. Click OK to save your changes and exit this screen. Disable the Touch Keyboard Service


The On-screen Keyboard Doesn't Appear When I Press the Enter , may appear if Virtual Remote Keyboard is set as the main keyboard setting. Under the System Preferences category, select Keyboard. Select Current Keyboard. Select Leanback Keyboard. Probably the keyboard app got corrupted. Try clearing application data + force stop for keyboard applications like HTC Keyboard, Google Keyboard, GBoard. That's how I got it working again for an HTC phone. - HTC Desire 816


Fix: On Screen Keyboard not working in Windows 10, On-screen keyboard not appearing Windows 10 – Some users are You can try these below mentioned On-Screen keyboard software on your� Note: If the user's device has an attached hardware keyboard, the soft input method does not appear. Show the input method on demand If there is a method in your activity's lifecycle where you want to ensure that the input method is visible, you can use the InputMethodManager to show it.


Handle input method visibility, Note: If the user's device has an attached hardware keyboard, the soft input method does not appear. Show the input method on demand. If there� The Keyboard or Type Cover appears to disconnect or stop responding randomly. The Keyboard or Type Cover goes back and forth between working, and not working. This can be either the Keyboard keys, touchpad, or the entire Keyboard or Type Cover. USB, Bluetooth, or on-screen keyboards may still work.