Can someone provide an example as to how to use the proximity sensor? I tried to use it the same way as other sensors, but it's not working.
This is the code snippet i have been using:
final SensorManager mSensorManager;
final Sensor mproximity;
mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
mproximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
mSensorManager.registerListener(new SensorListener(){
public void onAccuracyChanged(int arg0, int arg1) {
// TODO Auto-generated method stub
Toast.makeText(test.this,"proximity sensor accu ", Toast.LENGTH_SHORT).show();
}
public void onSensorChanged(int arg0, float[] arg1) {
// TODO Auto-generated method stub
Toast.makeText(test.this,"proximity sensor ", Toast.LENGTH_SHORT).show();
}
}, Sensor.TYPE_PROXIMITY, 1);
Please tell me where I am going wrong.