I want to change the theme based on value getting from sensor manager . But i don't know the range of it .

92 Views Asked by At
@Override
   public void onSensorChanged(SensorEvent event) {
    if(event.sensor.getType() == Sensor.TYPE_LIGHT){
     textLIGHT_reading.setText("LIGHT: " + event.values[0]);
    }
   }

Here i am getting 100 .Value will change based on the surrounding . I want to change the theme based on the value getting from sensor . Like for night i want dark theme and for day i want light theme . What is range for dark ? in sensor

1

There are 1 best solutions below

2
On
if(event.sensor.getType() == Sensor.TYPE_LIGHT){
 setTheme(android.R.style.Theme_Light);
 recreate();
 textLIGHT_reading.setText("LIGHT: " + event.values[0]);
} 
else {
   setTheme(android.R.style.Theme_Dark);   
   recreate();
}

Try the above solution !!