Created
September 1, 2022 15:00
-
-
Save DanishAmjad12/14a1ed3f82ac85060fa9123c7001efb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun galleryIntent() { | |
val galleryIntent:Intent | |
if (Build.VERSION.SDK_INT >= Versions.ANDROID_10) | |
galleryIntent = Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI) | |
else | |
galleryIntent = Intent() | |
galleryFile = FileUtils.createTempFileInStorage(this, FileUtil.getProfileName()) | |
galleryIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | |
galleryIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION) | |
galleryIntent.type = "image/*" | |
galleryIntent.action = Intent.ACTION_GET_CONTENT | |
galleryIntent.addCategory(Intent.CATEGORY_OPENABLE) | |
galleryIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileUtil.getUri(this, galleryFile)) | |
galleryIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) | |
if (galleryIntent.resolveActivity(packageManager) != null) { | |
startActivityForResult(galleryIntent, ReqCode.ACTIVITY_ANDROID_GALLERY) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment