我想關閉我的應用程序時,有三個手指觸摸屏幕(就像mac os)。在我的應用程序中,我使用了碎片和查看尋呼機,但我不明白如何使用event.getAction()和Action Mask。用三根手指觸摸後關閉Android應用程序
我所用的兩個
MotionEvent.ACTION_UP
MotionEvent.ACTION_POINTER_DOWN:
但他們沒有工作。
當使用不同的ACTION_MASKED應用程序被多次調用時。
int maxPointercount=0;
int previousPointercount=0;
public boolean onTouch(View v, MotionEvent event) {
int currentpointerCount = event.getPointerCount();
System.out.println("My pointer....." + currentpointerCount);
int action = event.getAction() & MotionEvent.ACTION_MASK;
System.out.println("pre......."+previousPointercount);
System.out.println("max......."+maxPointercount);
if(maxPointercount < previousPointercount){
maxPointercount = currentpointerCount;
}
previousPointercount = currentpointerCount;
if(action==MotionEvent.ACTION_) {
if(maxPointercount>=3){
maxPointercount = 0;
Toast.makeText(MyclassActivity.this,"FingerToched!!"Toast.LENGTH_SHORT).show();
Intent intent = newIntent(MyclassActivity.this,DashboardActivity.class);
startActivity(intent);
finish();
//your code that will run 1 time
}
maxPointercount = 0;
previousPointercount = 0;
}
return super.onTouchEvent(event);
}
我會質疑爲什麼。如果你想要OSX,那麼使用Mac。我會因爲關閉的應用程序而感到厭煩(我假設你正在做一些像system.exit這樣可怕的事情),只是因爲它檢測到3個手指。 – Simon 2013-03-01 07:52:10
我不明白你想說什麼..BR請用適當的語言解釋.. – Mahi 2013-03-01 07:55:37
@Lars Jensen ..感謝兄弟 – Mahi 2013-03-01 08:02:41