Java Code Examples for android.provider.Settings.SettingNotFoundException#printStackTrace()

The following examples show how to use android.provider.Settings.SettingNotFoundException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermissionManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public static boolean isLocationEnabled(Context context) {
    if (VERSION.SDK_INT >= 19) {
        try {
            if (Secure.getInt(context.getContentResolver(), "location_mode") != 0) {
                return true;
            }
            return false;
        } catch (SettingNotFoundException e) {
            e.printStackTrace();
            return false;
        }
    } else if (TextUtils.isEmpty(Secure.getString(context.getContentResolver(), "location_providers_allowed"))) {
        return false;
    } else {
        return true;
    }
}
 
Example 2
Source File: Helper.java    From Learning-Resources with MIT License 6 votes vote down vote up
/**
 * Is Roaming enabled.
 *
 * @return
 */
@SuppressWarnings("deprecation")
private static boolean isRoamingEnabled(Context ctx) {
    ContentResolver cr = ctx.getContentResolver();
    int result = 0; // 0 is false
    boolean check = false;

    try {
        result = Settings.Secure.getInt(cr, Settings.Secure.DATA_ROAMING);
    } catch (SettingNotFoundException e) {
        e.printStackTrace();
    }

    if (result == 1) {
        check = true;
    }

    return check;
}
 
Example 3
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@TargetApi(android.os.Build.VERSION_CODES.FROYO)
private void initBrightnessTouch() {
    float brightnesstemp = 0.6f;
    // Initialize the layoutParams screen brightness
    try {
        if (AndroidUtil.isFroyoOrLater() &&
                Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
            Settings.System.putInt(getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS_MODE,
                    Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
            mRestoreAutoBrightness = android.provider.Settings.System.getInt(getContentResolver(),
                    android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
        } else {
            brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
                android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
        }
    } catch (SettingNotFoundException e) {
        e.printStackTrace();
    }
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = brightnesstemp;
    getWindow().setAttributes(lp);
    mIsFirstBrightnessGesture = false;
}
 
Example 4
Source File: ConfirmationPrompt.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static boolean isAccessibilityServiceRunning(Context context) {
    boolean serviceRunning = false;
    try {
        ContentResolver contentResolver = context.getContentResolver();
        int a11yEnabled = Settings.Secure.getInt(contentResolver,
                Settings.Secure.ACCESSIBILITY_ENABLED);
        if (a11yEnabled == 1) {
            serviceRunning = true;
        }
    } catch (SettingNotFoundException e) {
        Log.w(TAG, "Unexpected SettingNotFoundException");
        e.printStackTrace();
    }
    return serviceRunning;
}
 
Example 5
Source File: AndroidIntegration.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
private static boolean isAccessibilitySettingsOn(Context ctx) {
    int accessibilityEnabled = 0;
    final String service = ctx.getPackageName() + "/"
            + OversecAccessibilityService_1.class.getName();
    boolean accessibilityFound = false;
    try {
        accessibilityEnabled = Settings.Secure.getInt(ctx
                        .getApplicationContext().getContentResolver(),
                Settings.Secure.ACCESSIBILITY_ENABLED);
    } catch (SettingNotFoundException e) {
        e.printStackTrace();
    }

    if (accessibilityEnabled == 1) {
        String settingValue = Settings.Secure.getString(ctx
                        .getApplicationContext().getContentResolver(),
                Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
        if (settingValue != null) {
            String[] values = settingValue.split("\\:");
            for (String string : values) {

                if (string.equalsIgnoreCase(service)) {
                    return true;
                }
            }
        }
    }
    return accessibilityFound;
}
 
Example 6
Source File: AndroidUtil.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
/**
 * 获取当前屏幕亮度,范围0-255
 * 
 * @param context
 * @return 屏幕当前亮度值
 */
public static int getScreenBrightness(Context context) {
	int rightnessValue = 0;
	try {
		rightnessValue = Settings.System.getInt(
				context.getContentResolver(),
				Settings.System.SCREEN_BRIGHTNESS);
	} catch (SettingNotFoundException e) {
		e.printStackTrace();
	}
	return rightnessValue;
}
 
Example 7
Source File: AndroidUtil.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
/**
 * 判断是否开启了自动亮度调节
 * 
 * @param context
 * @return
 */
public static boolean isAutomicBrightness(Context context) {
	boolean automicBrightness = false;
	try {
		automicBrightness = Settings.System.getInt(
				context.getContentResolver(),
				Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
	} catch (SettingNotFoundException e) {
		e.printStackTrace();
	}
	return automicBrightness;
}
 
Example 8
Source File: ControlLightness.java    From dttv-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * judge if auto open brightness
 *
 * @param context
 * @return
 */
public boolean isAutoBrightness(Context context) {
    boolean automicBrightness = false;
    ContentResolver ctr = context.getContentResolver();
    try {
        automicBrightness = Settings.System.getInt(ctr,
                Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
    } catch (SettingNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return automicBrightness;
}
 
Example 9
Source File: Utilities.java    From LiveBlurListView with Apache License 2.0 5 votes vote down vote up
public static boolean isAutoBrightness(ContentResolver aContentResolver) {
    boolean automicBrightness = false;
    try {
        automicBrightness = Settings.System.getInt(aContentResolver,
                Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
    } catch (SettingNotFoundException e) {
        e.printStackTrace();
    }
    return automicBrightness;
}