Background application to listen to drag gestures

I need to register a broadcast receiver that will tell me about any events Drag

throughout the system. My application will run in the background and perform any task if any event occurs Drag

, even any other application is running in the foreground. Is it possible? Any idea on how I can do this?

Updates: Don't think I'll make a keylogger. My app will be visible but will run in the background. And all I want is to just detect the drag events (drag left, drag right, drag and drag down). I will accept any answer if you tell me how I can display 4 buttons, which are permanent, on top of any other applications, because that can also serve me what I want.

+2


source to share


4 answers


I found the answer here . I need to start a service.



0


source


Your application might work without a "normal" user interface, working like Service

your link, but I think the associated code might be a little outdated.

Remember, your service must run in the foreground - the code is provided there in your link, but not explicitly called. Without running in the foreground, the system could stop your application instead of running it in the background.


When I created a task switcher using overlays like this, I found it was necessary to use TYPE_SYSTEM_ALERT

, not TYPE_SYSTEM_OVERLAY

.

I declare my window parameters without FLAG_WATCH_OUTSIDE_TOUCH

.



WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(width, height, x, y,
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
                PixelFormat.TRANSLUCENT);

      


Your service should also properly undo the overlay view from WindowManager

when it finishes. Without this, the application will leak memory.

public void onDestroy()
{
    super.onDestroy();
    if (overlay != null)
    {
        ((WindowManager) getSystemService(WINDOW_SERVICE)).removeView(overlay);
        overlay = null;
    }
}

      

I see this being done in OverlayView.destory()

(note the misspelling of this method name - it would be nice to use the correct name for this method).

+1


source


So your real requirement is to be able to pass some input to your application, allowing the screen to be dedicated for video output.

Have you thought about the following:

  • tilt or orientation detection device for direction control
  • with 4 nfc tags and detecting which one you jump from to change direction (may not give you a quick enough answer)

It is also possible to have actions that can be selected directly from notifications, so you can have one or more notifications that suggest actions to control the direction, and simply let the notification API handle the work that appears before the video.

Of course, there are applications that can overlay their interface in front of other applications. Thrutu is such an example, although it seems to you that you were pushed away for a while, and getting such a solution to work is not easy - see How to implement a drawer on the Android call screen?

0


source


The library icon allows you to create floating apps (apps that migrate to other apps). I've used this for several Android apps that I released to the market a while ago. This makes it pretty easy to create floating windows. Check it out at:
http://forum.xda-developers.com/showthread.php?t=1688531

0


source







All Articles