當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。