I am working on an application that is being distributed publicly. We have had some issues with soft keyboards showing up when edit text boxes are clicked (this is through an XML popup dialog), and found a solution, by toggling the soft keyboard into a forced state, through an onClickListener. (So it happens on the second click) This is not the issue anymore. The issue is that on our device, the forced keyboard stays open even when the user clicks the home button on their device. I will attach the code I used to get the keyboard to open.
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if(imm.isAcceptingText()){
//Toast.makeText(getApplicationContext(),""+imm.isAcceptingText(),Toast.LENGTH_LONG).show();
} else{
final AlertDialog.Builder dialog = new AlertDialog.Builder(ListResults.this).setTitle("").setMessage("If you are seeing this, please reboot your device.");
final AlertDialog alert = dialog.create();
alert.show();
final Handler handler = new Handler();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (alert.isShowing()) {
alert.dismiss();
}
}
};
alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
handler.removeCallbacks(runnable);
}
});
handler.postDelayed(runnable, 20);
}
//Toast.makeText(getApplicationContext(),""+imm.isAcceptingText(),Toast.LENGTH_LONG).show();
editGroup.requestFocus();
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,InputMethodManager.HIDE_IMPLICIT_ONLY);
This is designed to open the keyboard. The AlertDialog is a trick we found to get it to reset the imm.isAcceptingText and allow it to open the keyboard when it is forced. Before this, the keyboard did not open for us.
Now though, when anyone hits the home button on our android devices, the keyboard stays in the home screen until we click the back button, as I stated above. Is there a way to fix this, or some sort of work around to resolve this issue? I want the keyboard to close when the app is put into the background.