How to count only if light sensor event going from 100 to 50 and don't count if it from 0 to 50 ?
I'm using light sensor in my app( onsensorchange event ) I want to count only if light fade from 100 to 50% then add +1 to my counter
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sen = //get value of event.values[0]
}
});
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_LIGHT) {
if (sen => half of event.values[0]) {
// add +1 to my counter
}
}
}
the problem is they count when event.values[0] goes from 100 to 50 and from 0 to 50