I created a shortcut which its intent starts an Activity.
In the activity onCreate
I show a android.app.Dialog
with custom view.
I want to open the keyboard together with the activity/dialog.
The dialog layout:
<EditText
android:id="@+id/reminderEditText"
android:inputType="text"
android:maxLength="60"
android:maxLines="1"
android:hint="@string/remind_to"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<requestFocus />
</EditText>
The activity declaration in manifest:
<activity
android:name=".ReminderActivity"
android:windowSoftInputMode="stateAlwaysVisible"
android:label="@string/new_reminder"
android:exported="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
Activity onCreate()
:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.dialog_reminder, null);
EditText editText = view.findViewById(R.id.reminderEditText);
editText.requestFocus();
MaterialStyledDialog dialog = new MaterialStyledDialog.Builder(this)
.setIcon(R.drawable.ic_post_it_2)
.setCustomView(view, 20, 20, 20, 0)
.setPositiveText(android.R.string.ok)
.autoDismiss(true) // close dialog on callbakcs
.setCancelable(false) // not cancellable on outside touch
.show();
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
As you can see I've tried every solution I could find online regarding displaying keyboard automatically and yet, no success.
I've also tried the suggested solutions in this question but non of them worked.