I have following code uses light sensor but not able to display value of event.value[0]...it displays toast only with message "On SensorChanged" also text is not set to tv where i goes wrong..
here is code
public void onSensorChanged(SensorEvent event)
{
if( event.sensor.getType() == Sensor.TYPE_LIGHT)
{
tv.setText("value: " + event.values[0] + " lux" );
Toast.makeText(getApplicationContext(),"On SensorChanged"+ event.values[0],Toast.LENGTH_SHORT).show();
Log.d("Sensor Changed", "onSensor Change :" + brightness);
}
}
I dont think that is contains light sensors to that why it is returning nothing,your code seems fine otherwise,
http://www.gsmarena.com/samsung-phones-9.php
Follow this link to check the model you are testing on and see in features and then sensors