I have a view with an EditText that´s been added through WindowManager. I want to switch focus between my edit text and the edit text of other apps, let´s say WhatsApp, so I can type on both while my view is on screen. My problem is that if I use FLAG_NOT_FOCUSABLE the edit text in my view does not pull up the keyboard, only the edit text of the other apps in the phone, and if I use FLAG_NOT_TOUCH_MODAL the opposite happens. This is my method to call the floating view:
private fun setFloatingView() {
mFloatingView = OptionsViewBinding.inflate(context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)
as LayoutInflater)
//Add the view to the window.
val params = WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
layoutFlag,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL /** here is my problem**/,
PixelFormat.TRANSLUCENT
)
params.gravity =
Gravity.CENTER or Gravity.END
mWindowManager = context.getSystemService(WINDOW_SERVICE) as WindowManager
mWindowManager?.addView(mFloatingView?.root, params)
}
I have tried this:
val params = WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
layoutFlag,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT
)
But it´s not working, the flag_not_focusable function is the one used by the system so the keyboard on my Edit text is not pulling up the keyboard.
There are various questions in regards to the individual cases presented here, but none of them is about needing both features at the same time. I checked this , this and
.