2

I'm making an app in which in my Service I'm adding to Window Manager layout with edit text in it. Everything works fine, keyboard is showing up etc. However when I add second same layout to my window manager my first editext loses focus and I'm not able to type anything to it or maybe it's not losing focus because you can see a pointer but the keyboard is not showing up, it's showing up only last added layout.

I'm adding views to window manager like that:

params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
                PixelFormat.TRANSLUCENT);
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
singleLayout = inflater.inflate(R.layout.single_layout, null);
windowManager.addView(singleLayout, params);

I tried open a keyboard manually with that code:

InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

but it didn't work, this method also didn't work:

public static void forceFocusOnView(final View view) {
        if (view == null)
            return;
        view.post(new Runnable() {
            public void run() {
                view.clearFocus();
                view.post(new Runnable() {
                    public void run() {
                        view.requestFocus();
                    }
                });
            }
        });
    }

It's always showing keyboard only in last added layout, thanks for any solutions.

Janek
  • 101
  • 1
  • 1
  • 13
  • 1
    android:windowSoftInputMode="stateAlwaysVisible"------> in manifest File. edittext.requestFocus(); -------> in code. This will open soft keyboard on which edit-text has request focus as activity appears. – AndroUser Aug 14 '13 at 12:33
  • It's not an activity it's a service however I tried your solution - not working, keyboard still only showing in last added layout – Janek Aug 14 '13 at 12:38
  • @Janek have you got some solution to this – Rajnish Mishra Apr 25 '15 at 05:58

0 Answers0