Reputation: 335
So, earlier I posted a question about receiving touch events from a service (apparently no one knows the answer).
After trying to figure it out myself for hours, I gave up and decided to email a developer known as RubberBigPepper. I asked him how he did it in his app Volume control and he promptly responded "TYPE_SYSTEM_ALERT window".
What does this mean, and how can it be implemented in code?
EDIT:
I used the following method:
getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
and the window failed to receive touch events.
I emailed him about this as well and he says: "Use the WindowService to add your window"
Upvotes: 1
Views: 2801
Reputation: 26
I use code like this.
int nFlags=WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
m_cWM=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
nFlags,
PixelFormat.TRANSLUCENT);
m_cWM.addView(YourViewClass, lp);
And don't forget about uses-permissions
Upvotes: 1