Tuesday, 27 August 2013

Typing on an EditText without disturbing ongoing activity?

Typing on an EditText without disturbing ongoing activity?

So I am making a sticky note sorta thing that always appears on top and
user can press on it to type on it. So here is my working code:
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
LayoutInflater layoutInflater =
(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
myView = layoutInflater.inflate(R.layout.notepad, null ); //notepad.xml
contains the EditText
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
PixelFormat.TRANSLUCENT);
mWindowManager.addView(myView, params);
The problem is that when I use the flag TYPE_SYSTEM_OVERLAY, I can't get
focus to type on the EditText. Alternate would be to use TYPE_SYSTEM_ALERT
and I can use the EditText to type on, but then the entire background
would freeze. How can I allow the user to type without interrupting
background activity (aka game, video, scrolling thru Facebook etc)

No comments:

Post a Comment