How to Set ProgressBar Progress on Light Sensor Change

API Level 3 or greater needed.

1. Set the Upper Range of a ProgressBar to the Maximum Range of a Light Sensor named myProgressBar.

2. Determine if Sensor Light Changed

3. In the onSensorChanged method, add the following line after the float myEventValues is created. This convert the float value of myEventValues to an integer and set it to the Progress on the myProgressBar.


4. Compile and run!