The following applies to the Android operating system.
I am trying to estimate how dark (or light) it is in the room where the phone is located using the camera.
Using the camera is pointless, since the camera will adjust the exposure time and aperture to the surrounding light, so that the recorded images will have very similar overall brightness independent of the actual available light (at least in an ideal world).
The Android API offer functionality in the SensorManager to access the hardware sensors (you are interested in the sensor of type TYPE_LIGHT). I am not sure however, if you can rely on access to these sensors through the API, although they may (or may not) be present.