Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Method for starting the activity for selecting image from phone storage
- private fun pick() {
- verifyStoragePermissions(requireActivity())
- val intent = Intent(Intent.ACTION_GET_CONTENT)
- intent.type = "image/*"
- resultLauncher.launch(intent)
- }
- fun verifyStoragePermissions(activity: Activity?) {
- // Check if we have write permission
- val permission = ActivityCompat.checkSelfPermission(
- requireActivity(),
- WRITE_EXTERNAL_STORAGE
- )
- if (permission != PackageManager.PERMISSION_GRANTED) {
- // We don't have permission so prompt the user
- ActivityCompat.requestPermissions(
- requireActivity(),
- PERMISSIONS_STORAGE,
- REQUEST_EXTERNAL_STORAGE
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement