title: How to implement Back button functionality in android
body: <p>I want to implement back button functionality without pressing any hard keys. For example using proximity sensor. when any object comes to near to proximity I want to get previous activity. How to implement this in android is it possible ?. my code is like this :</p>
  
  <pre><code>SensorEventListener accelerometerSensorEventListener
          = new SensorEventListener(){
  
              public void onAccuracyChanged(Sensor sensor, int accuracy) {
                  // TODO Auto-generated method stub
  
              }
  
              public void onSensorChanged(SensorEvent event) {
                  // TODO Auto-generated method stub
  
                  if(event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){              
  
                       finish();                  
                  }
  
              }
  
       };
  </code></pre>
  
  <p>Thanks in advance</p>