Android Overlay Mouse Cursor
By Radu Motisan Posted on July 27th, 2012 , 14201 Views (Rate 27.74)
For an application developer it is important to have total freedom in shaping the result of his work.
Even if Android OS has been designed without the mouse cursor in mind, there are plenty of situations where a developer needs a cursor on top of other applications installed.
We can draw the cursor at the framebuffer level, and while this provides optimum performance, it requires special privileges that regular apps don't have.
The second approach , and the subject of this article, is drawing a cursor using an Overlay.
What is an overlay?
The SDK defines them as: "Window type: system overlay windows, which need to be displayed on top of everything else. These windows must not take input focus, or they will interfere with the keyguard. "
So what we are about to do is have a small view created, make it show a cursor image, and move it around.
Hope this code proves useful. Looking forward to your comments, questions and feedback,
Customizing the system's pointer
It is possible to detect the system mouse coordinates and draw a custom overlay on top of the system mouse cursor. This way we can increase the pointer image size, a very useful enhancement for those that have problems seeing the tiny default cursor. Here is a demo showing a bluetooth mouse cursor and our bigger custom mouse cursor overlay.
Demo app on Google play
Based on popular request, I finally developed a freeware application to customize the mouse cursor and provide a bigger cursor on Android OS, that runs on Android 4.0 or newer and doesn't need root!. It's named BigMouse and you can find it on Google Play here.
This app can be used both with Bluetooth Mouses and with wired mouses connected over OTG enabled USB.