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.
My response may be too incomplete for an answer, but I like the formatting here.
Additionally, my answer is not facetious, so don't stop reading right away.
Of course, first you'll have to take a picture. Then you'll have to define 'brightness'. I don't have the algorithm to do so, but I'm guessing something like that has already been done. Maybe something like :
Determine which pixel values are bright, which are dark and which are in between (and each of them can have a variable amount of brightness). You'll then have to apply that algorithm to your photograph to get a brightness value.
Yes, this is a very short (35,000 foot) view of the problem, but it should give you some ideas about where to start.
[edit]
Here is a place to start (the android documentation for sensors)
[/edit]