I want to implement proximity sensor in an application. But how can I make the application work in different phone.
Problem : There is an issue with Micromax A177 and Moto E as they seems to have proximity sensor but the min and max value is different. In case of Micromax I found it to be 0 and 1 on Sensor Box application, In case of Moto E it shows 3 and 100. Now what should be the comparing condition for an application as if I compare it with greater then 0 then it will be called all time in Moto E.
Any help is appreciated.
After registering the sensor, implemented listener code is Code used :
proximitySensorListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
// Here I have issue, How to make it working in case of all different phone.
if(event.values[0]>0)
{
methodCalled();
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
};
According to documentation:
So, you should just compare its value with your declared sensor as proximitySensor.getMaximumRange() and use it in your code.