get Sys Screen Brightness - Android android.provider

Android examples for android.provider:Settings

Description

get Sys Screen Brightness

Demo Code

import android.content.Context;
import android.provider.Settings;

public class Main {

  public static final int MAX_BRIGHTNESS = 255;

  static public int getSysScreenBrightness(Context context) {
    int screenBrightness = MAX_BRIGHTNESS;
    try {//from   ww w.ja  va2 s. com
      screenBrightness = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return screenBrightness;
  }

}

Related Tutorials