为什么我点击屏幕,ontouch事件2次
package com.game.guesswho.activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.app.Activity;
import android.content.Intent;
public class SplashActivity extends Activity {
private static final int ClOSE_THIS_ACTIVITY = 1;
private Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
//此处消息队列有2个相同的消息..
switch (msg.what) {
case ClOSE_THIS_ACTIVITY:
closeSplashWindow();
removeMessages(ClOSE_THIS_ACTIVITY);
break;
default:
break;
}
};
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
// 5秒钟之后关闭
// 发送延时的空消息
handler.sendEmptyMessageDelayed(ClOSE_THIS_ACTIVITY, 5000);
}
@Override
// 点击屏幕关闭
// 发送即时空消息
public boolean onTouchEvent(MotionEvent event) {
//
System.out.println("ontouch");
handler.sendEmptyMessage(ClOSE_THIS_ACTIVITY);
return super.onTouchEvent(event);
}
// 关闭页面函数
public void closeSplashWindow() {
Intent intent = new Intent(this, DebugActivity.class);
this.startActivity(intent);
finish();
}
}
|