Android 超好用的两次退出的代码
jopen
11年前
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } // 连击次数 2 long[] mHits = new long[2]; public void click(View view) { System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1); mHits[mHits.length - 1] = SystemClock.uptimeMillis(); Date date = new Date(SystemClock.uptimeMillis()); // 点击间隔时间 if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) { Toast.makeText(this, "我被2击了 ", 0).show(); } } }