我正在尝试从包裹中读取事件。适用于KeyEvents,但适用于MotionEvents,它给了我一个异常。我将数据转储到了包裹中,并在Input.cpp中查看了Android Source,但我仍然不明白出了什么问题。有任何想法吗?
try {
Parcel motionEventParcel = Parcel.obtain();
MotionEvent motionEvent = MotionEvent.obtain(millis, millis, MotionEvent.ACTION_DOWN, 100.0f, 100.0f, 0);
motionEvent.writeToParcel(motionEventParcel, 0);
MotionEvent motionEvent2 = MotionEvent.CREATOR.createFromParcel(motionEventParcel);
Log.i("test", "motion event passing succeeded");
}
catch (Throwable e) {
Log.e("test", "motion event passing failed: " + e.getMessage());
}
try {
Parcel keyEventParcel = Parcel.obtain();
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_A);
keyEvent.writeToParcel(keyEventParcel, 0);
KeyEvent keyEvent2 = KeyEvent.CREATOR.createFromParcel(keyEventParcel);
Log.i("test", "key event passing succeeded");
}
catch (Throwable e) {
Log.e("test", "key event passing failed: " + e.getMessage());
}