0

I am trying to simulate a set of clicks outside my app using a service but im not able to perform the clicks.

At the moment i use this example project: ChatHeads. So basically i the service initialises the following view:

public class HeadLayer extends View {

private Context mContext;
private FrameLayout mFrameLayout;
private WindowManager mWindowManager;

public HeadLayer(Context context) {
    super(context);

    mContext = context;
    mFrameLayout = new FrameLayout(mContext);

    addToWindowManager();
}

private void addToWindowManager() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.LEFT;

    mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.addView(mFrameLayout, params);

    LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Here is the place where you can inject whatever layout you want.
    layoutInflater.inflate(R.layout.head, mFrameLayout);
}

/**
 * Removes the view from window manager.
 */
public void destroy() {
    mWindowManager.removeView(mFrameLayout);
}

}

What do I want to achieve: After the user switches ON the Service I would like to perform a set of clicks with specific coordinates (X,Y) over the background content.

Example: I open a random app manually, lets say Play Store, then i want my service to perform a set of clicks (with coordinates x/y) over the opened app. For instance perform click on coordinates 123/453 witch on screen matches the link "Games". After this i perform another click with new pair of coordinates, and so on.

How can I perform these click?

Bugdr0id
  • 2,962
  • 6
  • 35
  • 59

0 Answers0