本文整理汇总了Java中android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS属性的典型用法代码示例。如果您正苦于以下问题:Java Settings.ACTION_MANAGE_WRITE_SETTINGS属性的具体用法?Java Settings.ACTION_MANAGE_WRITE_SETTINGS怎么用?Java Settings.ACTION_MANAGE_WRITE_SETTINGS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.Settings
的用法示例。
在下文中一共展示了Settings.ACTION_MANAGE_WRITE_SETTINGS属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveBrightness
/**
* 保存亮度设置状态
*/
public static void saveBrightness(Activity activity, int brightness) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(activity)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + activity.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
}
else {
try{
Uri uri = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS);
Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness);
// resolver.registerContentObserver(uri, true, myContentObserver);
activity.getContentResolver().notifyChange(uri, null);
}catch(Exception ex){
ex.printStackTrace();
}
}
}
示例2: stopAutoBrightness
/**
* 停止自动亮度调节
*
* @param activity
*/
public static void stopAutoBrightness(Activity activity) {
//动态申请权限
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(activity)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + activity.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
}
else {
Settings.System.putInt(activity.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}
}
示例3: getIntent
public static Intent getIntent(Context context,String permission) {
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M&&Manifest.permission.SYSTEM_ALERT_WINDOW.equals(permission)){
return new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
}else if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M&&Manifest.permission.WRITE_SETTINGS.equals(permission)){
return new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, Uri.parse("package:" + context.getPackageName()));
}else{
return getIntent(context);
}
}
示例4: setBrightness
@JSMethod
public void setBrightness(float brightness, JSCallback jsCallback){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mSetBritnessCallback = jsCallback;
mBritness = brightness;
Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + mWXSDKInstance.getContext().getPackageName()));
((Activity)mWXSDKInstance.getContext()).startActivityForResult(intent, Constant.WRITE_SETTINGS_REQUEST_CODE);
} else {
setBrightness(brightness);
getBrightness(jsCallback);
}
}
示例5: startAutoBrightness
/**
* 开启亮度自动调节
*
* @param activity
*/
public static void startAutoBrightness(Activity activity) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(activity)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + activity.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
}
else {
//有了权限,具体的动作
Settings.System.putInt(activity.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
}
}
示例6: startWriteSettingsActivityForResult
protected void startWriteSettingsActivityForResult() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + getContext().getPackageName()));
startActivityForResult(intent, REQUEST_CODE_WRITE_SETTINGS);
}
}
示例7: requestSystemWritePermission
public void requestSystemWritePermission(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + activity.getPackageName()));
activity.startActivity(intent);
}
}