16

Im trying to figure out how apps like swipe pad (https://market.android.com/details?id=mobi.conduction.swipepad.android) can hook guestures regardless of what window/app is on top, and how its able to draw and interact without stopping the background apps below it.

I have been able to create apps like dialogs and popup windows, but i cannot get them to show without stopping/freezing the background application.

UPDATE: found a suitable solution.

in your service's onCreate add this

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.setTitle("title");
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(layout, params);

touch events are handled just like regular except when you dont touch an element of the services gui, then the service doesnt read the touch and its dropped through to the underlying program

Dakun Skye
  • 580
  • 1
  • 4
  • 14
  • Rather than updating your original question, you should post an answer and then mark your own answer as the best answer for your question. – aberrant80 Jul 25 '11 at 02:13

1 Answers1

0

Using a combination of WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH and the solution to this question, I was able to do what you are trying to do without freezing the app the background.

Don't forget to include the uses-permission tag 'android.permission.SYSTEM_ALERT_WINDOW'.

Community
  • 1
  • 1
Gallal
  • 4,267
  • 6
  • 38
  • 61
  • yes, i forgot to mention, if you use the flag watch outside, it allows the app to receive touch events outside of the elements of the program. this causes a bit of a problem though if your app is right aligned or bottom alligned and the whole screen isnt being used. it causes the coordinates to be offset to the actual corner of the application as opposed to the screen – Dakun Skye Aug 17 '11 at 01:38