本文整理汇总了Java中android.provider.Settings.SettingNotFoundException方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.SettingNotFoundException方法的具体用法?Java Settings.SettingNotFoundException怎么用?Java Settings.SettingNotFoundException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.provider.Settings
的用法示例。
在下文中一共展示了Settings.SettingNotFoundException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSignInServiceEnabled
import android.provider.Settings; //导入方法依赖的package包/类
public static boolean isSignInServiceEnabled(Context context) {
int accessibilityEnabled = 0;
try {
accessibilityEnabled = Settings.Secure.getInt(context.getContentResolver(),
android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
if (accessibilityEnabled == 1) {
// get all the enabled service name, like:
// com.pyy.signin/com.pyy.signin.SignInService:com.baidu.appsearch/com.baidu.appsearch.util.AppAccessibilityService
String services = Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (services != null) {
// Check the enabled service is the same one with this app.
return services.toLowerCase().contains(context.getPackageName().toLowerCase());
}
}
return false;
}
示例2: isAccessibilitySettingsOn
import android.provider.Settings; //导入方法依赖的package包/类
private boolean isAccessibilitySettingsOn() {
int accessibilityEnabled = 0;
final String service = getPackageName() + "/" + NotificationService.class.getName();
boolean accessibilityFound = false;
try {
accessibilityEnabled = Settings.Secure.getInt(getApplicationContext().getContentResolver(), android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
} catch (Settings.SettingNotFoundException e) {
}
TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
if (accessibilityEnabled == 1) {
String settingValue = Settings.Secure.getString(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(service)) {
return true;
}
}
}
} else {
}
return accessibilityFound;
}
示例3: checkAccessibilityEnabled
import android.provider.Settings; //导入方法依赖的package包/类
/**
* 检测当前辅助服务是否开启
*/
public static boolean checkAccessibilityEnabled(Context context,Class<? extends AccessibilityService> clazz) {
int accessibilityEnabled = 0;
final String service = context.getPackageName() + "/" + clazz.getCanonicalName();
try {
accessibilityEnabled = Settings.Secure.getInt(context.getApplicationContext().getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED);
} catch (Settings.SettingNotFoundException ignored) {
// ignored
}
TextUtils.SimpleStringSplitter stringColonSplitter = new TextUtils.SimpleStringSplitter(':');
if (accessibilityEnabled == 1) {
String settingValue = Settings.Secure.getString(context.getApplicationContext().getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue != null) {
stringColonSplitter.setString(settingValue);
while (stringColonSplitter.hasNext()) {
String accessibilityService = stringColonSplitter.next();
if (accessibilityService.equalsIgnoreCase(service)) {
return true;
}
}
}
}
return false;
}
示例4: isAccessibilitySettingsOn
import android.provider.Settings; //导入方法依赖的package包/类
private boolean isAccessibilitySettingsOn(Context mContext) {
int accessibilityEnabled = 0;
final String service = getPackageName() + "/" + JumpService.class.getCanonicalName();
try {
accessibilityEnabled = Settings.Secure.getInt(
mContext.getApplicationContext().getContentResolver(),
android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
log.v( "accessibilityEnabled = " + accessibilityEnabled);
} catch (Settings.SettingNotFoundException e) {
log.d( "Error finding setting, default accessibility to not found: "
+ e.getMessage());
}
TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
if (accessibilityEnabled == 1) {
log.v( "***ACCESSIBILITY IS ENABLED*** -----------------");
String settingValue = Settings.Secure.getString(
mContext.getApplicationContext().getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue != null) {
mStringColonSplitter.setString(settingValue);
while (mStringColonSplitter.hasNext()) {
String accessibilityService = mStringColonSplitter.next();
log.v( "-------------- > accessibilityService :: " + accessibilityService + " " + service);
if (accessibilityService.equalsIgnoreCase(service)) {
log.v( "We've found the correct setting - accessibility is switched on!");
return true;
}
}
}
} else {
log.v( "***ACCESSIBILITY IS DISABLED***");
}
return false;
}
示例5: isAccessibilitySettingsOn
import android.provider.Settings; //导入方法依赖的package包/类
private boolean isAccessibilitySettingsOn(Context mContext) {
int accessibilityEnabled = 0;
final String service = getPackageName() + "/" + HelpService.class.getCanonicalName();
try {
accessibilityEnabled = Settings.Secure.getInt(
mContext.getApplicationContext().getContentResolver(),
android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
Log.v(TAG, "accessibilityEnabled = " + accessibilityEnabled);
} catch (Settings.SettingNotFoundException e) {
Log.e(TAG, "Error finding setting, default accessibility to not found: "
+ e.getMessage());
}
TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
if (accessibilityEnabled == 1) {
Log.v(TAG, "***ACCESSIBILITY IS ENABLED*** -----------------");
String settingValue = Settings.Secure.getString(
mContext.getApplicationContext().getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue != null) {
mStringColonSplitter.setString(settingValue);
while (mStringColonSplitter.hasNext()) {
String accessibilityService = mStringColonSplitter.next();
Log.v(TAG, "-------------- > accessibilityService :: " + accessibilityService + " " + service);
if (accessibilityService.equalsIgnoreCase(service)) {
Log.v(TAG, "We've found the correct setting - accessibility is switched on!");
return true;
}
}
}
} else {
Log.v(TAG, "***ACCESSIBILITY IS DISABLED***");
}
return false;
}
示例6: refresh
import android.provider.Settings; //导入方法依赖的package包/类
public void refresh() {
int enabled = 0;
try {
enabled = Settings.System.getInt(getContentResolver(), "pointer_location");
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
getQsTile().setState(enabled == 1 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
getQsTile().updateTile();
}
示例7: getSleepDuration
import android.provider.Settings; //导入方法依赖的package包/类
/**
* 获取进入休眠时长
*
* @return 进入休眠时长,报错返回-123
*/
public static int getSleepDuration() {
try {
return Settings.System.getInt(Utils.getApp().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
return -123;
}
}
示例8: isAccessibilitySettingsOn
import android.provider.Settings; //导入方法依赖的package包/类
/**
* Checks if the Forge Auto fill accessibility service is enabled
*
* @param context application context
* @return true = service enabled, false = service disabled
*/
public static boolean isAccessibilitySettingsOn(Context context) {
int accessibilityEnabled = 0;
final String service = context.getPackageName() + "/" + AccessibilityAutofillService.class.getCanonicalName();
try {
accessibilityEnabled = Settings.Secure.getInt(
context.getApplicationContext().getContentResolver(),
android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
} catch (Settings.SettingNotFoundException e) {
// If there is an error, log it
Log.e(Forge.ERROR_LOG, e.getMessage());
}
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) {
mStringColonSplitter.setString(settingValue);
while (mStringColonSplitter.hasNext()) {
String accessibilityService = mStringColonSplitter.next();
if (accessibilityService.equalsIgnoreCase(service)) {
return true;
}
}
}
}
return false;
}
示例9: get
import android.provider.Settings; //导入方法依赖的package包/类
public static int get(Context context) {
ContentResolver cResolver = context.getContentResolver();
try {
return Settings.System.getInt(cResolver, Settings.System.SCREEN_BRIGHTNESS);
} catch (Settings.SettingNotFoundException e) {
return 0;
}
}
示例10: isAutoBrightness
import android.provider.Settings; //导入方法依赖的package包/类
/**
* 判断是否开启了自动亮度调节
*/
public static boolean isAutoBrightness(Activity activity) {
boolean isAuto = false;
try {
isAuto = Settings.System.getInt(activity.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
} catch (Settings.SettingNotFoundException e){
e.printStackTrace();
}
return isAuto;
}
示例11: isAirplaneEnabled
import android.provider.Settings; //导入方法依赖的package包/类
@ReactMethod
public void isAirplaneEnabled(Promise promise) {
try {
int val = Settings.System.getInt(getReactApplicationContext().getContentResolver(), Settings.System.AIRPLANE_MODE_ON);
promise.resolve(val == 1);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
promise.reject("-1", "get airplane mode fail", e);
}
}
示例12: isAccessibilitySettingsOn
import android.provider.Settings; //导入方法依赖的package包/类
private boolean isAccessibilitySettingsOn(Context mContext) {
int accessibilityEnabled = 0;
final String service = getPackageName() + "/" + getPackageName() + ".MyService";
boolean accessibilityFound = false;
try {
accessibilityEnabled = Settings.Secure.getInt(
mContext.getApplicationContext().getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED);
Log.v("MainActivity","accessibilityEnabled = " + accessibilityEnabled);
} catch (Settings.SettingNotFoundException e) {
Log.e("MainActivity","Error finding setting, default accessibility to not found: "
+ e.getMessage());
}
TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
if (accessibilityEnabled == 1) {
Log.v("MainActivity","***ACCESSIBILIY IS ENABLED*** -----------------");
String settingValue = Settings.Secure.getString(
mContext.getApplicationContext().getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue != null) {
TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
splitter.setString(settingValue);
while (splitter.hasNext()) {
String accessabilityService = splitter.next();
Log.v("MainActivity","-------------- > accessabilityService :: " + accessabilityService);
if (accessabilityService.equalsIgnoreCase(service)) {
Log.v("MainActivity","We've found the correct setting - accessibility is switched on!");
return true;
}
}
}
} else {
Log.v("MainActivity","***ACCESSIBILIY IS DISABLED***");
}
return accessibilityFound;
}
示例13: setBrightness
import android.provider.Settings; //导入方法依赖的package包/类
public void setBrightness(float value) {
int screenMode = 0;
try {
screenMode = Settings.System.getInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
if(screenMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC){
setScreenMode(Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}
Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, (int) value*255);
}
示例14: installingFromUnknownSourcesAllowed
import android.provider.Settings; //导入方法依赖的package包/类
/**
* Returns whether the user has enabled installing apps from sources other than the Google Play
* Store.
*/
private static boolean installingFromUnknownSourcesAllowed(Context context) {
try {
return Settings.Secure.getInt(
context.getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS)
== 1;
} catch (Settings.SettingNotFoundException e) {
return false;
}
}
示例15: setBrightness
import android.provider.Settings; //导入方法依赖的package包/类
public void setBrightness(float value) {
int screenMode = 0;
try {
screenMode = Settings.System.getInt(mWXSDKInstance.getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
if(screenMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC){
setScreenMode(Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}
Settings.System.putInt(mWXSDKInstance.getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, (int) (value * 255));
}