java.lang.IllegalArgumentException: pointerIndex out of range

Q:在做多点触控放大缩小,操作自己所绘制的图形时发生这个异常


A:bug是Android系统原因

1.修改frameworks\base\core\jni\android_view_MotionEvent.cpp
的android_view_MotionEvent_nativeGetAxisValue方法注释掉

if (!validatePointerIndex(env, pointerIndex, pointerCount)) 
{return 0;}

2.捕获IllegalArgumentException异常

private float spacing(MotionEvent event) {
    try {
        x = event.getX(0) - event.getX(1);
        y = event.getY(0) - event.getY(1);
    } catch (IllegalArgumentException e) {      
        e.printStackTrace();
    }

你可能感兴趣的:(java.lang.IllegalArgumentException: pointerIndex out of range)