本文整理匯總了Java中android.provider.Settings.SettingNotFoundException類的典型用法代碼示例。如果您正苦於以下問題:Java SettingNotFoundException類的具體用法?Java SettingNotFoundException怎麽用?Java SettingNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SettingNotFoundException類屬於android.provider.Settings包,在下文中一共展示了SettingNotFoundException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isAccessibilitySettingsOn
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
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;
}
示例2: onChange
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
@Override
public void onChange(boolean selfChange) {
// Retrieve the current system brightness value
int currentBrightness;
try {
currentBrightness = (int) (((PlayerActivity)mContext).getWindow().getAttributes().screenBrightness*255f);
if(currentBrightness<=0) //read global brightness setting when not set on window
currentBrightness = Settings.System.getInt(mContentResolver, Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
currentBrightness = DEFAULT_BACKLIGHT;
}
// The brightness has already been applied by the system, we just need to update the slider
mSeekBar.setProgress(currentBrightness - MINIMUM_BACKLIGHT);
}
示例3: isGpsLocationEnabled
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
/**
* Check if the GPS location is enabled on this device.
*
* @return <code>true</code> if the GPS location is enabled, <code>false</code> if it's disabled
*/
@SuppressWarnings("deprecation")
@SuppressLint("InlinedApi")
private boolean isGpsLocationEnabled() {
int locationMode = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
} catch (SettingNotFoundException e) {
Log.e(LOG_TAG, "LocationMode option is not set.", e);
}
return locationMode != Settings.Secure.LOCATION_MODE_OFF;
} else {
String locationProviders;
locationProviders = Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
}
}
示例4: GetCurrentBrightness
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
public int GetCurrentBrightness() {
_logger.Debug("GetCurrentBrightness");
ContentResolver contentResolver = _context.getContentResolver();
int brightness = -1;
try {
Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
brightness = Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
_logger.Error(e.toString());
}
return brightness;
}
示例5: isLocationEnabled
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
public boolean isLocationEnabled() {
int locationMode = 0;
String locationProviders;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
try
{
locationMode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE);
}
catch (SettingNotFoundException e) {
}
return locationMode != Settings.Secure.LOCATION_MODE_OFF;
}
else{
locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
}
}
示例6: getActualState
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
@Override
public int getActualState(Context context) {
try {
current = Settings.System.getInt(context.getContentResolver(),
Settings.System.SCREEN_OFF_TIMEOUT);
current = current < mModes[mLastIndex] ?
(current <= mModes[0] ? mModes[0] : current) : mModes[mLastIndex];
} catch (final SettingNotFoundException e) { }
if (current == mModes[mLastIndex]) {
return STATE_ENABLED;
} else if (current == mModes[0]) {
return STATE_DISABLED;
} else {
return STATE_INTERMEDIATE;
}
}
示例7: getActualState
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
@Override
public int getActualState(Context context) {
try {
auto = android.provider.Settings.System.getInt(
context.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE);
current = android.provider.Settings.System.getInt(
context.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
current = current < mModes[mLastIndex] ?
(current <= mModes[0] ? mModes[0] : current) : mModes[mLastIndex];
} catch (final SettingNotFoundException e) { }
if (current == mModes[mLastIndex]) {
return STATE_ENABLED;
} else if (current == mModes[0]) {
return STATE_DISABLED;
} else {
return STATE_INTERMEDIATE;
}
}
示例8: D
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
public static boolean D(Context paramContext)
{
int i1 = Build.VERSION.SDK_INT;
boolean bool = false;
ContentResolver localContentResolver;
if (i1 >= 21) {
localContentResolver = paramContext.getContentResolver();
}
try
{
int i2 = Settings.Secure.getInt(localContentResolver, "high_text_contrast_enabled");
bool = false;
if (i2 != 0) {
bool = true;
}
return bool;
}
catch (Settings.SettingNotFoundException localSettingNotFoundException) {}
return false;
}
示例9: initBrightnessTouch
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
@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;
}
示例10: backLightStatus
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
public int backLightStatus()
{
int backLight=0;
try {
backLight = Settings.System.getInt(QtApplication.mainActivity().getContentResolver(),Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
if((backLight<=BRIGHTNESS_ON) && (backLight>=BRIGHTNESS_DIM))
{
return 2;
}
else if((backLight>=BRIGHTNESS_OFF) && (backLight<=BRIGHTNESS_DIM))
{
return 1;
}
else if(backLight==BRIGHTNESS_OFF)
{
return 0;
}
else
{
return -1;
}
}
示例11: isLocationEnabled
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
private boolean isLocationEnabled() {
int locationMode = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
try {
locationMode = Secure.getInt(mContext.getContentResolver(), Secure.LOCATION_MODE);
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
return locationMode != Secure.LOCATION_MODE_OFF;
} else {
return isLocationEnabled_Deprecated();
}
}
示例12: getLocationMode
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
@SuppressLint("InlinedApi")
private int getLocationMode() throws SettingNotFoundException {
int apiLevel = Integer.valueOf(android.os.Build.VERSION.SDK_INT);
if (apiLevel < 19) {
LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean isGpsEnabled = manager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (isGpsEnabled) {
return 3;
} else {
return 0;
}
} else {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.LOCATION_MODE);
}
}
示例13: isLocationEnabled
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
public static boolean isLocationEnabled(Context context) {
int locationMode = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
locationMode = Secure.getInt(context.getContentResolver(), Secure.LOCATION_MODE);
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
return locationMode != Secure.LOCATION_MODE_OFF;
} else {
String locationProviders = Secure.getString(context.getContentResolver(),
Secure.LOCATION_PROVIDERS_ALLOWED);
return !locationProviders.isEmpty();
}
}
示例14: estimateEnergyLocal
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
private static Estimate estimateEnergyLocal(Context context,
String methodName, float weight, boolean screenOn)
throws NoHistoryException {
// start with the local execution time
Estimate result = estimateExecutionTimeLocal(context, methodName,
weight);
// assume that we use Max Power (Homer to the Max ;-)) for the CPU
// during the execution time
double power = ContextState.maxOf(context, "cpu.active");
if (screenOn) {
double screen = ContextState.valueOf(context, "screen.on");
double screenFull = ContextState.valueOf(context, "screen.full");
try {
power += screen
+ (Settings.System.getInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS) / 255.0f)
* (screenFull - screen);
} catch (SettingNotFoundException e) {
// assume half brightness
power += screen + 0.5 * (screenFull - screen);
}
}
result.average *= power;
result.variance *= (power * power);
return result;
}
示例15: isLocationEnabled
import android.provider.Settings.SettingNotFoundException; //導入依賴的package包/類
/**
* Gets the status of the location service.
*
* @param context
* @return
*/
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.KITKAT)
public static boolean isLocationEnabled(Context context) {
int locationMode = 0;
String locationProviders;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
locationMode = Settings.Secure.LOCATION_MODE_OFF;
try {
locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
} catch (SettingNotFoundException e) {}
return locationMode != Settings.Secure.LOCATION_MODE_OFF;
}else{
locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
}
}