Androidメモ: ソフトウェアキーボードを常に表示する (setSoftInputMode)

Android アプリケーションでソフトウェアキーボードを常に表示したいときは次のように実装します。

方法 1) Activity の onCreate() で設定する
public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    }
}
方法 2) Dialog 表示時に設定
final AlertDialog dialog = ...;
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);