How to activate the screen when the motion detector detects something?

advertisements

Is there any way to turn screen on when motion sensor detects than phone is moved? Thanks in advance.


Consider something like this

//implement SensorEventListener
public class SensorActivity extends Activity, implements SensorEventListener {
......

SensorManager sensorMan = (SensorManager)getSystemService(SENSOR_SERVICE);
Sensor sensor = sensorMan.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

sensorMan.registerListener(context, sensor,
    SensorManager.SENSOR_DELAY_UI);

@Override
 public void onSensorChanged(SensorEvent event) {

     if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){

      }
     //Or some other sensor.
  }

There's more info in the docs here