android记录点击次数

    long[] mHits = new long[3];
    long[] mHits5 = new long[5];


  @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
 if (preference.getKey().equals(KEY_SERIAL_NUMBER)) {
             Log.e(LOG_TAG, "zhanbing.li");
             System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
            mHits[mHits.length-1] = SystemClock.uptimeMillis();
             if (mHits[0] >= (SystemClock.uptimeMillis()-500)) {
              ComponentName toActivity = new ComponentName("com.test.pcbatest","com.test.pcbatest.PcbaTestActivity");
   Intent intent = new Intent(Intent.ACTION_MAIN);
   intent.setComponent(toActivity);
               intent.setAction("android.intent.action.VIEW");
                 try {
                      startActivity(intent);
                 } catch (Exception e) {
    Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
   }    
  }
   } else if (preference.getKey().equals(KEY_GAUGE_VERSION)) {
                Log.e(LOG_TAG, "zhanbing.li Gauge three clicks");
                System.arraycopy(mHits5, 1, mHits5, 0, mHits5.length-1);
                mHits5[mHits5.length-1] = SystemClock.uptimeMillis();
                if (mHits5[0] >= (SystemClock.uptimeMillis()-1000)) {
   if (!mBatteryCharging) {
    File writeGaugeFile = new File("/sys/power/wakeups/needtoreset_gauge");
    FileWriter fr;
    int reboot_flag = 0;
                  try{
     fr = new FileWriter(writeGaugeFile);
                          fr.write("1");
                          Log.e(LOG_TAG, "/************************* reset gauge write success ***************************/\n");
                          fr.close();
     reboot_flag = 1;
    } catch (IOException e) {
     e.printStackTrace();
                  }
    if (reboot_flag == 1){
     Toast.makeText(Status.this, "Reset gauge sucess, system will restart", Toast.LENGTH_LONG).show();
                   Log.e(LOG_TAG, "/***********************start to reboot ***************************/\n");
                   Intent intent = new Intent(Intent.ACTION_REBOOT);
                   intent.putExtra("nowait", 1);
                   intent.putExtra("interval", 1);
                   intent.putExtra("window", 0);
                   sendBroadcast(intent);
    } else {
     Log.e(LOG_TAG, "fail to reset gauge\n");
    }
   } else {
     Toast.makeText(Status.this, "Please remove your DC or Usb first!", Toast.LENGTH_SHORT).show();
   }
  }
        }
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值