I'm deploying an app which create a cursor using a OverlayView. I'm able to move it around the screen and outside my app (service).
But now I want to implement the touch event. I'm running the cursor in a service, so I can still move it in the menu or anywhere. But I don't know how to make a click.
So once I'm outside my app if this service gets a click event (programmatically or remotely), I want to make a touch event on the view under my cursor.
Any idea how to get the view under it or how to send a system touch event?
This is how I control and draw the cursor:
class OverlayView extends ViewGroup {
private Paint mLoadPaint;
boolean mShowCursor;
Bitmap cursor;
public int x = 0,y = 0;
public void Update(int nx, int ny) {
x = nx; y = ny;
}
public void ShowCursor(boolean status) {
mShowCursor = status;
}
public boolean isCursorShown() {
return mShowCursor;
}
public OverlayView(Context context) {
super(context);
cursor = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher);
mLoadPaint = new Paint();
mLoadPaint.setAntiAlias(true);
mLoadPaint.setTextSize(10);
mLoadPaint.setARGB(255, 255, 0, 0);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//canvas.drawText("Hello World", 0, 0, mLoadPaint);
if (mShowCursor) canvas.drawBitmap(cursor,x,y,null);
}
@Override
protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) {
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return true;
}
Thank you