1.android处理双击事件
- // 计算点击的次数
- private int count = 0;
- // 第一次点击的时间 long型
- private long firstClick = 0;
- // 最后一次点击的时间
- private long lastClick = 0;
- private ButtonOnTouchListener listener = new ButtonOnTouchListener();
- private class ButtonOnTouchListener implements OnTouchListener
- {
- @Override
- public boolean onTouch(View v, MotionEvent event)
- {
-
- if (event.getAction() == MotionEvent.ACTION_DOWN)
- {
- // 如果第二次点击 距离第一次点击时间过长 那么将第二次点击看为第一次点击
- if (firstClick != 0 && System.currentTimeMillis() - firstClick > 500)
- {
- count = 0;
- }
- count++;
- if (count == 1)
- {
- firstClick = System.currentTimeMillis();
- }
- else if (count == 2)
- {
- lastClick = System.currentTimeMillis();
- // 两次点击小于500ms 也就是连续点击
- if (lastClick - firstClick < 500)
- {
- //Log.v("Double", "Double");
- if (vv.isScale())
- {
- vv.setScale(false);
- }
- else
- {
- vv.setScale(true);
- }
- }
- clear();
- }
- }
-
- return false;
-
- // 清空状态
- private void clear()
- {
- count = 0;
- firstClick = 0;
- lastClick = 0;
- }
- }
2.android灭屏
- + PowerManager pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
- + pm.goToSleep(SystemClock.uptimeMillis());
3.AndroidManifest.xml修改
添加系统权限
- <manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- + android:sharedUserId="android.uid.system">
-
- <permission
- + <uses-permission android:name="android.permission.DEVICE_POWER" />
4.Android.mk中增加如下代码:
LOCAL_CERTIFICATE := platform