How do I change the brightness level of the camera?
Steve
Using the camera parameters as pointed out by @appleskin, would either of these methods help? setWhiteBalance() or setExposureCompensation()
You can pass your camera parameters.
Try parameters.set("iso", 400); or whatever int value is supported on your device
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
}
}
来源:https://stackoverflow.com/questions/5432503/how-to-increase-brightness-of-camera-in-android