1 只有一个屏幕情况下,双指触发移动会crash
解决办法:
如果没有2个屏幕,则压根不触发任何移动操作

代码:
@Override
public void onPointerEvent(MotionEvent motionEvent) {
android.util.Log.i("DoubleScreenTouch","DoubleScreenMovePointerEventListener onPointerEvent motionEvent = "+motionEvent + " mService.mRoot.getChildCount() = " +mService.mRoot.getChildCount());
if (mService.mRoot.getChildCount() != 2) {
return;
}
//省略其他
}
在只有一个屏幕的设备上,如果尝试双指触发移动操作会导致程序崩溃。解决这个问题的方法是检查屏幕数量,如果不满足两个屏幕的条件,则不执行任何移动操作的代码。通过在`onPointerEvent`方法中判断`mService.mRoot.getChildCount()`是否为2来实现这一逻辑。
32万+

被折叠的 条评论
为什么被折叠?



