title: In Android, how can I delay onSensorChanged?
body: <p>I have an issue with an app I'm creating. Essentially, the app should only launch if proximity sensor is blocked (something is near), and as soon as it gets unblocked it should run finish(). I've tried this</p>
  
  <pre><code>    public void onSensorChanged(SensorEvent event) {
      if (event.values[0] == 0) {
          iv.setImageResource(R.drawable.logotwo);
      } else {
          finish();
      }
  }
  </code></pre>
  
  <p>but the app immediately closes as it can't read the proximity sensor fast enough. If I do</p>
  
  <pre><code>public void onSensorChanged(SensorEvent event) {
  if (event.values[0] == 0) {
      iv.setImageResource(R.drawable.logotwo);
  } else {
      iv.setImageResource(R.drawable.logoone);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>it recognises the sensor and displays the two images just fine depending on the sensor being blocked or not. </p>
  
  <p>So how can I  call finish() when the sensor is not obstructed without the app just not launching? </p>