Simulate the Home key operation and disable the mobile phone keypad in Android Development
1. When you click return, you do not want to exit the application. Directly simulate the HOME key operation. You can write it in the onKeyDown event or in other places you want to implement:
Intent intent = new Intent (Intent. ACTION_MAIN );
// Create a new task stack (this must be written)
Intent. addFlags (Intent. FLAG_ACTIVITY_NEW_TASK );
Intent. addCategory (Intent. CATEGORY_HOME );
This. startActivity (intent );
2. Disable the mobile phone keypad for listening:
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
If (inputMethodManager! = Null & this. getCurrentFocus ()! = Null ){
InputMethodManager. hideSoftInputFromWindow (this. getCurrentFocus (). getWindowToken (),
InputMethodManager. HIDE_NOT_ALWAYS );
}
3,