Example #1
0
  @Override
  protected void onResume() {
    Log.v(ac_tag, "onResume");
    super.onResume();

    Calendar c = Calendar.getInstance();
    int weekIndex = c.get(Calendar.DAY_OF_WEEK) - 1;

    this.timeView.setText(
        ""
            + decimalFormat.format(c.get(Calendar.HOUR_OF_DAY))
            + ":"
            + decimalFormat.format(c.get(Calendar.MINUTE)));
    this.dateView.setText(
        ""
            + decimalFormat.format(c.get(Calendar.MONTH) + 1)
            + "月"
            + decimalFormat.format(c.get(Calendar.DAY_OF_MONTH))
            + "日  "
            + weekDaysName[weekIndex]);

    this.mPassView.setVisibility(View.GONE);

    this.pbCircle.setVisibility(View.INVISIBLE);
    this.progressView.setAlpha(1f);
    this.progressView.setVisibility(View.VISIBLE);
    this.progressView.setText("正在初始化...");
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    boolean isScreenOn = pm.isScreenOn();
    if (isScreenOn) {
      if (audioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
        isRecording = false;
      } else {
        if (isRecording == false) {
          audioRecord.startRecording();
          isRecording = true;
        }
        STask = new SecondsRoundTask();

        ATask = new AuthenTask();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
          STask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
          ATask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
          STask.execute();
          ATask.execute();
        }
      }
    }
  }
Example #2
0
  @Override
  protected void onPause() {
    Log.v(ac_tag, "onPause");
    super.onPause();

    if (ATask != null) {
      ATask.cancel(true);
    }
    if (STask != null) {
      STask.cancel(true);
    }
    isRecording = false;
    if (audioRecord != null) {
      if (audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
        audioRecord.stop();
      }
    }
  }