I have an activity that only has a EditText. I want the soft keyboard to show up automatically. How can I do this?
            Asked
            
        
        
            Active
            
        
            Viewed 5,046 times
        
    1 Answers
4
            You can use this onResume:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(((EditText) findViewById(R.id.your_view)),InputMethodManager.SHOW_FORCED);
I suggest that you check if there is a Hardware keyboard before you force the keyboard to appear.
To hide:
((InputMethodManager) YourActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(findViewById(R.id.YOUR_VIEW).getWindowToken(), 0);
EDIT:
Try this:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
 
    
    
        neteinstein
        
- 17,529
- 11
- 93
- 123
- 
                    Add a timer to call it 2 or 3 seconds after onResume – neteinstein May 24 '11 at 12:39
