private void load_write_permession(){ if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M && Build.VERSION.SDK_INT<Build.VERSION_CODES.Q){ if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermissionLauncher.launch( Manifest.permission.WRITE_EXTERNAL_STORAGE); } } } private ActivityResultLauncher<String> requestPermissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> { if (isGranted) { } else { finish(); //CLOSE } });
沒有留言:
張貼留言