Samsung Galaxy S4 have the "Floating Touch" functionality, in which the finger can be detected even if the screen is not touched.
I would like to fire an event on a button (btn1) when the finger is passing hover it.
I tried using the OnHoverListener, but "onHover" never get called when the MotionEvent is MotionEvent.ACTION_HOVER_ENTER or MotionEvent.ACTION_HOVER_EXIT or MotionEvent.ACTION_HOVER_MOVE, which are the event that I need.
This is my code:
btn1.setOnHoverListener(new OnHoverListener() {
@Override
public boolean onHover(View v, MotionEvent event) {
Log.d("FloatingTouch", "onHover: "+event.getAction());
switch (event.getAction()) {
case MotionEvent.ACTION_HOVER_ENTER:
Log.d("FloatingTouch", "ACTION_HOVER_ENTER" );
return true;
case MotionEvent.ACTION_HOVER_MOVE:
Log.d("FloatingTouch", "ACTION_HOVER_MOVE" );
return true;
case MotionEvent.ACTION_HOVER_EXIT:
Log.d("FloatingTouch", "ACTION_HOVER_EXIT" );
break;
default:
break;
}
return false;
}
});
Do I miss something? Maybe some permission?