title: Proximity sensor to wake up the android device is not working
body: <p>I am trying to wake up my android device using the proximity sensor but it not working when the phone is in sleep..Please any body tell me how to do it.OR Is there any ways to wake up the android device without using the power button?
  Here is my code.</p>
  
  <pre><code>public class SensorActivity extends Activity implements SensorEventListener {
  private SensorManager mSensorManager;
  private Sensor mProximity;
  
  
  private PowerManager mPowerManager;
  private PowerManager.WakeLock mWakeLock;
  
  @Override
  public final void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  
      mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
      mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
  
  
  
  
  
  }
  
  @Override
  public final void onAccuracyChanged(Sensor sensor, int accuracy) {
  
      this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
                      WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                      WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                      WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
              WindowManager.LayoutParams.FLAG_FULLSCREEN |
                      WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                      WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                      WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  
  }
  
  @Override
  public final void onSensorChanged(SensorEvent event) {
      float distance = event.values[0];
  
      System.out.println("DistanceDistance"+distance);
  
  
  }
  
  @Override
  protected void onResume() {
  
      super.onResume();
      mSensorManager.registerListener(this, mProximity, SensorManager.SENSOR_DELAY_NORMAL);
  }
  
  @Override
  protected void onPause() {
  
      super.onPause();
      mSensorManager.unregisterListener(this);
  }}
  </code></pre>