Text

Only recognize the stylus, not finger

I have developing an application to Samsung Note, and I want only recognize the stylus. I don want to recognize finger. It is possible How I can set this in multi line widget?

Regardss


Dear Customer,

It is indeed possible to make the difference in between stylus and finger events. Here is an example:

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static boolean isStylusMotionEvent(MotionEvent event, int pointerIndex)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
if (event.getToolType(pointerIndex) == MotionEvent.TOOL_TYPE_STYLUS)
return true;

return false;
}


Best regards,

Olivier

I want to use only the stylus pen. Can i disable finger?

The event.getToolType function allows to detect touch events with finger as well:

if(event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER) {
//finger touch


If you want to read more about it:
http://developer.android.com/reference/android/view/MotionEvent.html

Best regards

Can i get the same answer for iOS (Objective C)?

The equivalent on iOS seems to be UITouchType:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITouch_Class/
UITouchType

Constants
• UITouchTypeDirect
A direct touch from a finger on the screen.
Available in iOS 9.0 and later.
• UITouchTypeIndirect
An indirect touch, not on a screen.
Available in iOS 9.0 and later.
•UITouchTypeStylus
A touch from a stylus.
Available in iOS 9.1 and later


Hope it helps.
Best regards

Login or Signup to post a comment