title: Display soft keyboard automatically on a dialog activity
body: <p>I have a simple Activity that uses a <code>android:theme="@android:style/Theme.Dialog"</code> in the manifest.</p>
  
  <p>My activity consists of an EditText, 2 Buttons, and a TextView.  It is nothing more than a box for the user to enter in a name and press OK/Cancel.</p>
  
  <p>I just want to focus the EditText and have the soft keyboard automatically show when the Activity is started.  I've read countless posts about this but I just can't seem to get it to work.  When the activity starts the blinking cursor appears in the EditText, but the keyboard won't show until I click inside it.</p>
  
  <p>Here is my Activity:</p>
  
  <pre><code>public class Finalize extends Activity {
  
      private EditText mEditName;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.finalize_dialog);
  
          mEditName = (EditText) findViewById(R.id.file_name_edit);
          mEditName.setFocusable(true);
          mEditName.requestFocus();
  
          mEditName.setOnFocusChangeListener(new View.OnFocusChangeListener() {           
              @Override
              public void onFocusChange(View v, boolean hasFocus) {
                  getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
              }
          });
      }
  }
  </code></pre>
  
  <p>I've also tried this in onCreate:</p>
  
  <pre><code>    InputMethodManager mgr = (InputMethodManager) getSystemService(this.INPUT_METHOD_SERVICE);
      mgr.showSoftInput(mEditName, 0);
  </code></pre>
  
  <p>Edit:  My manifest for reference</p>
  
  <pre><code>    &lt;activity class=".Finalize"
          android:name=".Finalize"
          android:label="@string/file_name_title"
          android:theme="@android:style/Theme.Dialog"
          android:screenOrientation="portrait"        
          android:windowSoftInputMode="stateAlwaysVisible"&gt;
      &lt;/activity&gt;
  </code></pre>