InputMethodManager imm = (InputMethodManager)
this.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isAcceptingText()) {
System.out.println("Software Keyboard was shown");
} else {
System.out.println("Software Keyboard is hidden");
}
This does the trick. I checked if the soft key board is opened it stays at the current activity, otherwise it goes to previous activity.