Open askarsyzdykov opened 8 years ago
if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED){ getImages(); }else{ if(shouldShowRequestPermissionRationale(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)){ Toast.makeText(this, "External Storage Required to Save Photos", Toast.LENGTH_SHORT).show(); } requestPermissions(new String[] {android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.CAMERA}, REQUEST_EXTERNAL_STORAGE_RESULT); } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if(requestCode == REQUEST_EXTERNAL_STORAGE_RESULT){ if(grantResults[0] == PackageManager.PERMISSION_GRANTED){ getImages(); } else{ Toast.makeText(ViewOneGalleryActivity.this, "External Write Permissions have not been granted, cannot save images", Toast.LENGTH_SHORT).show(); } } else{ super.onRequestPermissionsResult(requestCode, permissions, grantResults); } } private void getImages() { Intent intent = new Intent(this, ImagePickerActivity.class); Config config = new Config.Builder() .setTabBackgroundColor(R.color.white) // set tab background color. Default white. .setTabSelectionIndicatorColor(R.color.blue) .setCameraButtonColor(R.color.green) .setSelectionLimit(50) // set photo selection limit. Default unlimited selection. .build(); ImagePickerActivity.setConfig(config); startActivityForResult(intent, 200); }