当前位置: 首页>>代码示例>>Java>>正文


Java Settings.ACTION_MANAGE_WRITE_SETTINGS属性代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:22,代码来源:BrightnessUtils.java

示例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);
    }

}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:20,代码来源:BrightnessUtils.java

示例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);
    }
}
 
开发者ID:paozhuanyinyu,项目名称:XPermission,代码行数:9,代码来源:PermissionsPageManager.java

示例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);
    }
}
 
开发者ID:natjs,项目名称:nat-explorer,代码行数:13,代码来源:DeviceScreen.java

示例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);
    }
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:19,代码来源:BrightnessUtils.java

示例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);
    }
}
 
开发者ID:fendoudebb,项目名称:PlayAndroid,代码行数:7,代码来源:CheckPermissionsFragment.java

示例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);
  }
}
 
开发者ID:nisrulz,项目名称:lantern,代码行数:7,代码来源:Lantern.java


注:本文中的android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。