Search code examples
javaandroidsensorsproximity

how to switch button on and off using proximity sensor?


i am developing an app that uses proximity sensor.i am doing this app as my project at college.so I would like to know how can I use the button turn off and on using the proximity sensor.thanks in advance.


Solution

  • @Override
     public void onSensorChanged(SensorEvent event) {
     // TODO Auto-generated method stub
      if(event.sensor.getType()==Sensor.TYPE_PROXIMITY){
    
          //Toggle button here   
       }
    }