Example usage for android.app Activity getContentResolver

List of usage examples for android.app Activity getContentResolver

Introduction

In this page you can find the example usage for android.app Activity getContentResolver.

Prototype

@Override
    public ContentResolver getContentResolver() 

Source Link

Usage

From source file:Main.java

public static void setSystemBrightness(int brightness, Activity a) {
    Settings.System.putInt(a.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS,
            (int) brightness);
}

From source file:Main.java

public static void stopAutoBrightness(Activity activity) {
    Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE,
            Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}

From source file:Main.java

public static String getDeviceUdid(Activity activity) {
    return Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID);
}

From source file:Main.java

public static String getImei(Activity act) {
    String androidID = System.getString(act.getContentResolver(), System.ANDROID_ID);
    return androidID;

}

From source file:Main.java

public static void startAutoBrightness(Activity activity) {
    Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE,
            Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
}

From source file:Main.java

private static InputStream getDeviceFileAsInputStream(Uri uri, Activity activity) throws FileNotFoundException {
    return activity.getContentResolver().openInputStream(uri);
}

From source file:Main.java

public static void stopAutoBrightness(Activity activity) {
    try {/*from   w  ww .jav a  2 s .c om*/
        Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE,
                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void saveBrightness(Activity activity, int brightness) {
    ContentResolver resolver = activity.getContentResolver();
    Uri uri = android.provider.Settings.System.getUriFor("screen_brightness");
    android.provider.Settings.System.putInt(resolver, "screen_brightness", brightness);
    // resolver.registerContentObserver(uri, true, myContentObserver);
    resolver.notifyChange(uri, null);/* w  w w .j a  v  a  2 s. co  m*/
}

From source file:Main.java

public static boolean isAutoBrightness(Activity activity) {
    ContentResolver aContentResolver = activity.getContentResolver();
    boolean automicBrightness = false;
    try {//  w w  w .ja va  2s  .com
        automicBrightness = Settings.System.getInt(aContentResolver,
                Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
    } catch (SettingNotFoundException e) {
        e.printStackTrace();
    }
    return automicBrightness;
}

From source file:Main.java

public static void setBrightness(Activity activity) {
    ContentResolver resolver = activity.getContentResolver();
    Uri uri = Settings.System.getUriFor("screen_brightness");
    int nowScreenBri = getScreenBrightness(activity);
    nowScreenBri = nowScreenBri <= 225 ? nowScreenBri + 30 : 30;
    System.out.println("nowScreenBri==" + nowScreenBri);
    Settings.System.putInt(resolver, "screen_brightness", nowScreenBri);
    resolver.notifyChange(uri, null);//from  ww w . j  av a2 s.c o  m
}