private void updateProximitySensorMode(float proximityX) {
    synchronized (mProximityWakeLock) {
      if (proximityX == 1f) {
        if (!mProximityWakeLock.isHeld()) {
          Log.d(TAG, "updateProximitySensorMode: acquiring...");
          mProximityWakeLock.acquire();
        } else {
          Log.d(TAG, "updateProximitySensorMode: lock already held.");
        }
      } else {
        if (mProximityWakeLock.isHeld()) {
          if (DBG) {
            Log.d(TAG, "updateProximitySensorMode: releasing...");
          }

          mProximityWakeLock.release();

          mCurrentCount++;
          pCurrent.setText(getString(R.string.proximity_timer_current, mCurrentCount));
        } else {
          Log.d(TAG, "updateProximitySensorMode: lock already released.");
        }
      }
    }
  }
Esempio n. 2
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   // TODO Auto-generated method stub
   Log.d(this, "onActivityResult, requestCode = " + requestCode + ",resultCode = " + resultCode);
   if (resultCode == Activity.RESULT_OK) {
     mPhotoView.setImageURI(mTempPhotoUri);
   }
   super.onActivityResult(requestCode, resultCode, data);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sensor_proximity);

    initWidget();

    if (mExistProximity) {
      mSensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
      mSensor = mSensorMgr.getDefaultSensor(Sensor.TYPE_PROXIMITY);
      mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);

      // Wake lock used to control proximity sensor behavior.
      if (mPowerManager.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) {
        mProximityWakeLock =
            mPowerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, TAG);
      }

      Log.d(TAG, "onCreate: mProximityWakeLock: " + mProximityWakeLock);
    }
  }