My issue is that my custom alertdialog class is not displaying the softkeyboard correctly. I am creating it using
SettingsDialog settingsDialog = new SettingsDialog(MainActivity.this);
settingsDialog.show();
And the softkeyboard is not displaying. I've followed other stackoverflow answers to displaying the keyboard ... Show soft keyboard for dialog
and it works if I do not use a custom class
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
mBuilder.setView(R.layout.alertdialog_settings);
AlertDialog alertDialog = mBuilder.create();
alertDialog.show();
However when using a custom AlertDialog class I can't seem to get the same outcome as the picture above
I have tried manually displaying the keyboard
SettingsDialog settingsDialog = new SettingsDialog(MainActivity.this);
settingsDialog.show();
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
if(imm != null){
   imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
However it shows the keyboard behind the alertdialog and doesn't give the same effect as AlertDialog Builder.
How can I display the softkeyboard using a Custom AlertDialog to have output as using AlertDialog Builder?
Edit:
I have also tried manually displaying it in the AlertDialog's onCreate Method
public class SettingsDialog extends AlertDialog {
     public SettingsDialog(@NonNull Context context, String subName) {
            super(context);
            this.mContext = context;
            this.mSubName = subName;
     }
     @Override
     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.alertdialog_settings);
        InputMethodManager imm = (InputMethodManager) 
        mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        if(imm != null){
          imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
        }
     }
}
However this still causes the keyboard to be displayed behind the alertDialog


 
     
    