How do I change the brightness level of the camera?
Asked
Active
Viewed 2.0k times
5
-
do you have solve this problem? – Tomero Indonesia Aug 05 '20 at 23:12
4 Answers
7
Using the camera parameters as pointed out by @appleskin, would either of these methods help? setWhiteBalance() or setExposureCompensation()

Steve
- 1,439
- 2
- 14
- 27
-
thank for your kind response steve, but both the function are not available in api level 7 – Sunil Pandey Mar 29 '11 at 03:41
-
2ah, do you specifically need the brightness to be at the point of taking the photo? Or can you post-process the image to brighten it as soon as it is taken? It just might be a limitation you can't work around without upgrading the OS. – Steve Mar 29 '11 at 20:24
-1
used following way to increase or decrease brightness ( its for activity so you can used anywhere for camera or activity also), its working fine.so it helping to anyone.
call following function in your activity :
private void setSeekbar() {
seekBar.setMax(255);
float curBrightnessValue = 0;
try {
curBrightnessValue = android.provider.Settings.System.getInt(
getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
int screen_brightness = (int) curBrightnessValue;
seekBar.setProgress(screen_brightness);
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// Nothing handled here
}
public void onStartTrackingTouch(SeekBar seekBar) {
// Nothing handled here
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// Set the minimal brightness level
// if seek bar is 20 or any value below
screenBrightness(progress);
editor.putInt("brightness",progress);
editor.commit();
}
});
}
method of screenBrightness :
private void screenBrightness(double newBrightnessValue) {
/*
* WindowManager.LayoutParams settings = getWindow().getAttributes();
* settings.screenBrightness = newBrightnessValue;
* getWindow().setAttributes(settings);
*/
WindowManager.LayoutParams lp = getWindow().getAttributes();
float newBrightness = (float) newBrightnessValue;
lp.screenBrightness = newBrightness / (float) 255;
getWindow().setAttributes(lp);
}
following method call before SeekBarChangeListener :
void changeBrightnessMode() {
try {
int brightnessMode = Settings.System.getInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE);
if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}
} catch (Exception e) {
// do something useful
}
}

Nirav Mehta
- 1,715
- 4
- 23
- 42
-
the code you posted let you adjust brightness of Android System not cameraPreview brightness – Zar E Ahmer Apr 13 '15 at 07:05
-
We want increase brightness of custom camera(Preview) not screen brightness. if you done that please share. – Chetan Chaudhari Jun 28 '19 at 08:04
-