In general the screen brightness varies in between 0 to 255. The below snippet helps to find the screen brightness.
public static int getScreenBrightness(Context context)
{
try
{
return Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
}
catch (SettingNotFoundException e)
{
Log.e("getScreenBrightness()", ""+e.getMessage());
return -1;
}
}
We have to pass context of the activity from where we are calling this method.
This method will return screen brightness as a result.
public static int getScreenBrightness(Context context)
{
try
{
return Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
}
catch (SettingNotFoundException e)
{
Log.e("getScreenBrightness()", ""+e.getMessage());
return -1;
}
}
We have to pass context of the activity from where we are calling this method.
This method will return screen brightness as a result.