get System Screen Brightness - Android android.provider

Android examples for android.provider:Settings

Description

get System 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   w w  w .  java 2 s .c  o  m
      screenBrightness = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return screenBrightness;
  }

}

Related Tutorials