NKJ
NKJ

Reputation: 1

How to change input focus from floating app window to another application at the background?

I am relatively new to Android programming and encountered a problem which I have spent days to resolve but to no avail.

I developed a floating window application that runs concurrently with another application at the background. There is an editText in my floating window. While I am able to touch and navigate the background application (with my floating window on-screen) using the below layout parameters:

final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.
            WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);

, I am unable to input on an editText in the background application. Anything I type using the soft keyboard appears in my floating app's editText instead. So here's my question:

How do we change input focus from a floating app to the background application? And change it back to the floating app upon pressing on the editText field in it?

I will greatly appreciate it if somebody can give me the solution to this problem. Thank you so much!

Upvotes: 0

Views: 717

Answers (1)

Irwin Nawrocki
Irwin Nawrocki

Reputation: 344

You might try to

editText.requestFocus();

when editText is clicked (setOnClickListener).

Also worth checking is you EditText focusable (in xml layout definition)

android:focusable="true"

Upvotes: 0

Related Questions