David
David

Reputation: 325

Android: Possible to get hover usb mouse coordinates? (without any clicks)

I need to get mouse coordinates with just hovering the usb mouse above my app's view.

the function public boolean onTouchEvent(MotionEvent event) { only works when I actually click the mouse.

any way to do it? thanks!

Upvotes: 1

Views: 159

Answers (2)

Gabe Sechan
Gabe Sechan

Reputation: 93561

Try to set an OnHoverListener via setOnHoverListener. Its mainly meant for styluses, but it may work with a mouse as well.

Upvotes: 2

Fountain Enabler
Fountain Enabler

Reputation: 27

As far as the emulator knows, there's no such thing as a mouse. I'm assuming you want this for testing purposes, but as far as the emulator is concerned, you're basically asking the device to track your finger without touching the screen.

Upvotes: 0

Related Questions