类android.provider.Settings.SettingNotFoundException源码实例Demo

下面列出了怎么用android.provider.Settings.SettingNotFoundException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: FimiX8-RE   文件: PermissionManager.java
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;
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: ConfirmationPrompt.java
private int getUiOptionsAsFlags() {
    int uiOptionsAsFlags = 0;
    try {
        ContentResolver contentResolver = mContext.getContentResolver();
        int inversionEnabled = Settings.Secure.getInt(contentResolver,
                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
        if (inversionEnabled == 1) {
            uiOptionsAsFlags |= UI_OPTION_ACCESSIBILITY_INVERTED_FLAG;
        }
        float fontScale = Settings.System.getFloat(contentResolver,
                Settings.System.FONT_SCALE);
        if (fontScale > 1.0) {
            uiOptionsAsFlags |= UI_OPTION_ACCESSIBILITY_MAGNIFIED_FLAG;
        }
    } catch (SettingNotFoundException e) {
        Log.w(TAG, "Unexpected SettingNotFoundException");
    }
    return uiOptionsAsFlags;
}
 
public boolean locationServicesEnabled() throws PluginException {
    Context context = getContext();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int locationMode = 0;
        try {
            locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
            return locationMode != Settings.Secure.LOCATION_MODE_OFF;
        } catch (SettingNotFoundException e) {
            logger.error("Location services check failed", e);
            throw new PluginException("Location services check failed", e, PluginException.SETTINGS_ERROR);
        }
    } else {
        String locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
        return !TextUtils.isEmpty(locationProviders);
    }
}
 
public static boolean isAccessibilitySettingsOn(Context context, String serviceName) {
    int accessibilityEnabled = 0;
    boolean accessibilityFound = false;
    try {
        accessibilityEnabled = Settings.Secure.getInt(context.getApplicationContext().getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED);
    } catch (SettingNotFoundException e) {
    }
    TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
    if (accessibilityEnabled == 1) {
        String settingValue = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
        if (settingValue != null) {
            TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
            splitter.setString(settingValue);
            while (splitter.hasNext()) {
                String accessabilityService = splitter.next();
                if (accessabilityService.equalsIgnoreCase(serviceName)) {
                    return true;
                }
            }
        }
    } else {
        // Log.v(TAG, "***ACCESSIBILIY IS DISABLED***");
    }

    return accessibilityFound;
}
 
源代码5 项目: Learning-Resources   文件: Helper.java
/**
 * 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;
}
 
源代码6 项目: VCL-Android   文件: VideoPlayerActivity.java
@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;
}
 
@Override
public boolean isBleScanAlwaysAvailable() {
    if (isAirplaneModeOn() && !mEnable) {
        return false;
    }
    try {
        return Settings.Global.getInt(mContentResolver,
                Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE) != 0;
    } catch (SettingNotFoundException e) {
    }
    return false;
}
 
源代码8 项目: android_9.0.0_r45   文件: VibratorService.java
private boolean updateInputDeviceVibratorsLocked() {
    boolean changed = false;
    boolean vibrateInputDevices = false;
    try {
        vibrateInputDevices = Settings.System.getIntForUser(
                mContext.getContentResolver(),
                Settings.System.VIBRATE_INPUT_DEVICES, UserHandle.USER_CURRENT) > 0;
    } catch (SettingNotFoundException snfe) {
    }
    if (vibrateInputDevices != mVibrateInputDevicesSetting) {
        changed = true;
        mVibrateInputDevicesSetting = vibrateInputDevices;
    }

    if (mVibrateInputDevicesSetting) {
        if (!mInputDeviceListenerRegistered) {
            mInputDeviceListenerRegistered = true;
            mIm.registerInputDeviceListener(this, mH);
        }
    } else {
        if (mInputDeviceListenerRegistered) {
            mInputDeviceListenerRegistered = false;
            mIm.unregisterInputDeviceListener(this);
        }
    }

    mInputDeviceVibrators.clear();
    if (mVibrateInputDevicesSetting) {
        int[] ids = mIm.getInputDeviceIds();
        for (int i = 0; i < ids.length; i++) {
            InputDevice device = mIm.getInputDevice(ids[i]);
            Vibrator vibrator = device.getVibrator();
            if (vibrator.hasVibrator()) {
                mInputDeviceVibrators.add(vibrator);
            }
        }
        return true;
    }
    return changed;
}
 
源代码9 项目: android_9.0.0_r45   文件: VibratorService.java
private int runVibrate() {
    Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "runVibrate");
    try {
        try {
            final int zenMode = Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.ZEN_MODE);
            if (zenMode != Settings.Global.ZEN_MODE_OFF) {
                try (PrintWriter pw = getOutPrintWriter();) {
                    pw.print("Ignoring because device is on DND mode ");
                    pw.println(DebugUtils.flagsToString(Settings.Global.class, "ZEN_MODE_",
                            zenMode));
                    return 0;
                }
            }
        } catch (SettingNotFoundException e) {
            // ignore
        }

        final long duration = Long.parseLong(getNextArgRequired());
        if (duration > MAX_VIBRATION_MS) {
            throw new IllegalArgumentException("maximum duration is " + MAX_VIBRATION_MS);
        }
        String description = getNextArg();
        if (description == null) {
            description = "Shell command";
        }

        VibrationEffect effect =
                VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE);
        vibrate(Binder.getCallingUid(), description, effect, AudioAttributes.USAGE_UNKNOWN,
                mToken);
        return 0;
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR);
    }
}
 
源代码10 项目: android_9.0.0_r45   文件: PowerManagerService.java
private void incrementBootCount() {
    synchronized (mLock) {
        int count;
        try {
            count = Settings.Global.getInt(
                    getContext().getContentResolver(), Settings.Global.BOOT_COUNT);
        } catch (SettingNotFoundException e) {
            count = 0;
        }
        Settings.Global.putInt(
                getContext().getContentResolver(), Settings.Global.BOOT_COUNT, count + 1);
    }
}
 
源代码11 项目: android_9.0.0_r45   文件: InputManagerService.java
private int getPointerSpeedSetting() {
    int speed = InputManager.DEFAULT_POINTER_SPEED;
    try {
        speed = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.POINTER_SPEED, UserHandle.USER_CURRENT);
    } catch (SettingNotFoundException snfe) {
    }
    return speed;
}
 
源代码12 项目: android_9.0.0_r45   文件: InputManagerService.java
private int getShowTouchesSetting(int defaultValue) {
    int result = defaultValue;
    try {
        result = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.SHOW_TOUCHES, UserHandle.USER_CURRENT);
    } catch (SettingNotFoundException snfe) {
    }
    return result;
}
 
源代码13 项目: android_9.0.0_r45   文件: ConfirmationPrompt.java
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;
}
 
源代码14 项目: android_9.0.0_r45   文件: CardEmulation.java
/**
 * Returns whether the user has allowed AIDs registered in the
 * specified category to be handled by a service that is preferred
 * by the foreground application, instead of by a pre-configured default.
 *
 * Foreground applications can set such preferences using the
 * {@link #setPreferredService(Activity, ComponentName)} method.
 *
 * @param category The category, e.g. {@link #CATEGORY_PAYMENT}
 * @return whether AIDs in the category can be handled by a service
 *         specified by the foreground app.
 */
public boolean categoryAllowsForegroundPreference(String category) {
    if (CATEGORY_PAYMENT.equals(category)) {
        boolean preferForeground = false;
        try {
            preferForeground = Settings.Secure.getInt(mContext.getContentResolver(),
                    Settings.Secure.NFC_PAYMENT_FOREGROUND) != 0;
        } catch (SettingNotFoundException e) {
        }
        return preferForeground;
    } else {
        // Allowed for all other categories
        return true;
    }
}
 
源代码15 项目: android_9.0.0_r45   文件: DownloadManager.java
/**
 * Returns maximum size, in bytes, of downloads that may go over a mobile connection; or null if
 * there's no limit
 *
 * @param context the {@link Context} to use for accessing the {@link ContentResolver}
 * @return maximum size, in bytes, of downloads that may go over a mobile connection; or null if
 * there's no limit
 */
public static Long getMaxBytesOverMobile(Context context) {
    try {
        return Settings.Global.getLong(context.getContentResolver(),
                Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
    } catch (SettingNotFoundException exc) {
        return null;
    }
}
 
源代码16 项目: openboard   文件: ImportantNoticeUtils.java
@UsedForTesting
static boolean isInSystemSetupWizard(final Context context) {
    try {
        final int userSetupComplete = Settings.Secure.getInt(
                context.getContentResolver(), Settings_Secure_USER_SETUP_COMPLETE);
        return userSetupComplete == USER_SETUP_IS_NOT_COMPLETE;
    } catch (final SettingNotFoundException e) {
        Log.w(TAG, "Can't find settings in Settings.Secure: key="
                + Settings_Secure_USER_SETUP_COMPLETE);
        return false;
    }
}
 
源代码17 项目: styT   文件: EnergyWrapper.java
public int getBrightness()
   {
   	int mOldBrightness = 0;
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    mOldBrightness = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS);
       }
catch (SettingNotFoundException snfe)
{
    mOldBrightness = 255;    }

       return mOldBrightness;
   }
 
源代码18 项目: styT   文件: EnergyWrapper.java
public int getBacklightTime()
   {
   	int Time = 0;    	
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    Time = Settings.System.getInt(cr, Settings.System.SCREEN_OFF_TIMEOUT);
       }
catch (SettingNotFoundException snfe) 
       {
    //Log.d(tag,"error()");    
       }

       return Time;
   }
 
源代码19 项目: styT   文件: EnergyWrapper.java
public int getBluetoothStatus()
   {
   	int iStatus = 0;
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    iStatus = Settings.Secure.getInt(cr, Settings.Secure.BLUETOOTH_ON);
       }
catch (SettingNotFoundException snfe)
{
    iStatus = 0;    }
       return iStatus;
   }
 
源代码20 项目: styT   文件: EnergyWrapper.java
public int getWiFiStatus()
   {
   	int iStatus = 0;
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    iStatus = Settings.Secure.getInt(cr, Settings.Secure.WIFI_ON);
       }
catch (SettingNotFoundException snfe)
{
    iStatus = 0;    }
       return iStatus;
   }
 
源代码21 项目: oversec   文件: AndroidIntegration.java
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;
}
 
源代码22 项目: Linphone4Android   文件: LinphoneManager.java
public void playDtmf(ContentResolver r, char dtmf) {
	try {
		if (Settings.System.getInt(r, Settings.System.DTMF_TONE_WHEN_DIALING) == 0) {
			// audible touch disabled: don't play on speaker, only send in outgoing stream
			return;
		}
	} catch (SettingNotFoundException e) {}

	getLc().playDtmf(dtmf, -1);
}
 
源代码23 项目: stynico   文件: EnergyWrapper.java
public int getBrightness()
   {
   	int mOldBrightness = 0;
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    mOldBrightness = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS);
       }
catch (SettingNotFoundException snfe)
{
    mOldBrightness = 255;    }

       return mOldBrightness;
   }
 
源代码24 项目: stynico   文件: EnergyWrapper.java
public int getBacklightTime()
   {
   	int Time = 0;    	
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    Time = Settings.System.getInt(cr, Settings.System.SCREEN_OFF_TIMEOUT);
       }
catch (SettingNotFoundException snfe) 
       {
    //Log.d(tag,"error()");    
       }

       return Time;
   }
 
源代码25 项目: stynico   文件: EnergyWrapper.java
public int getBluetoothStatus()
   {
   	int iStatus = 0;
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    iStatus = Settings.Secure.getInt(cr, Settings.Secure.BLUETOOTH_ON);
       }
catch (SettingNotFoundException snfe)
{
    iStatus = 0;    }
       return iStatus;
   }
 
源代码26 项目: stynico   文件: EnergyWrapper.java
public int getWiFiStatus()
   {
   	int iStatus = 0;
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    iStatus = Settings.Secure.getInt(cr, Settings.Secure.WIFI_ON);
       }
catch (SettingNotFoundException snfe)
{
    iStatus = 0;    }
       return iStatus;
   }
 
源代码27 项目: AOSP-Kayboard-7.1.2   文件: ImportantNoticeUtils.java
@UsedForTesting
static boolean isInSystemSetupWizard(final Context context) {
    try {
        final int userSetupComplete = Settings.Secure.getInt(
                context.getContentResolver(), Settings_Secure_USER_SETUP_COMPLETE);
        return userSetupComplete == USER_SETUP_IS_NOT_COMPLETE;
    } catch (final SettingNotFoundException e) {
        Log.w(TAG, "Can't find settings in Settings.Secure: key="
                + Settings_Secure_USER_SETUP_COMPLETE);
        return false;
    }
}
 
源代码28 项目: letv   文件: BasePlayController.java
private int getScreenBrightness() {
    int screenBrightness = 255;
    try {
        screenBrightness = System.getInt(getActivity().getContentResolver(), "screen_brightness");
    } catch (SettingNotFoundException e) {
    }
    return screenBrightness;
}
 
源代码29 项目: NewsMe   文件: AndroidUtil.java
/**
 * 获取当前屏幕亮度,范围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;
}
 
源代码30 项目: NewsMe   文件: AndroidUtil.java
/**
 * 判断是否开启了自动亮度调节
 * 
 * @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;
}
 
 类所在包
 类方法
 同包方法