Java tutorial
//package com.java2s; import android.view.MotionEvent; public class Main { /** * Identifies if the provided {@link MotionEvent} is a stylus with the primary stylus button * pressed. * * @param event The event to check. * @return Whether a stylus button press occurred. */ public static boolean isStylusButtonPressed(MotionEvent event) { return event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS && event.isButtonPressed(MotionEvent.BUTTON_SECONDARY); } }