Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import android.app.Activity;
import android.content.ContentResolver;

import android.provider.Settings;

public class Main {
    public static float getScreenBrightness(Activity activity) {
        float nowBrightnessValue = -1;
        ContentResolver resolver = activity.getContentResolver();
        try {
            nowBrightnessValue = android.provider.Settings.System.getInt(resolver,
                    Settings.System.SCREEN_BRIGHTNESS, -1);

            nowBrightnessValue /= 255;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return nowBrightnessValue;
    }
}