我在包含editText的服务中显示自定义对话框。问题是聚焦editText时不会出现软键盘。
Service.java
screenParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE,
PixelFormat.TRANSLUCENT);
screenParams.gravity = Gravity.TOP | Gravity.LEFT;
screenParams.x = 0;
screenParams.y = 0;
textLayout.setVisibility(View.VISIBLE);
editText.requestFocus();
windowManager.updateViewLayout(screen, screenParams);
layout.xml
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/newText"
android:inputType="textAutoComplete|text"
android:focusable="true"
android:focusableInTouchMode="true" />