object(mysqli_result)#13 (5) { ["current_field"]=> int(0) ["field_count"]=> int(25) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } 手機設定 - 保存亮度 - 程序員論壇 - Powered by Discuz!

程序員論壇

標題: 手機設定 - 保存亮度 [打印本頁]

作者: GreenCup    時間: 2019-12-5 02:42
標題: 手機設定 - 保存亮度
Java Code Examples for android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS

保存亮度設置狀態
  1. public static void saveBrightness(Activity activity, int brightness) {

  2.     if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(activity)) {
  3.         Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
  4.         intent.setData(Uri.parse("package:" + activity.getPackageName()));
  5.         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6.         activity.startActivity(intent);
  7.     }
  8.     else {
  9.         try{
  10.             Uri uri = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS);
  11.             Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness);
  12.             // resolver.registerContentObserver(uri, true, myContentObserver);
  13.             activity.getContentResolver().notifyChange(uri, null);
  14.         }catch(Exception ex){
  15.             ex.printStackTrace();
  16.         }
  17.     }
  18. }
複製代碼





歡迎光臨 程序員論壇 (http://program.thesmartfire.com/) Powered by Discuz! X2.5