Consider implementing app, that lets user to pick images taken with camera from Gallery, and then using those pics on app.
Project settings are:
targetSdk=34, compileSdk=34, minSdk=22
Using MediaStore API, I can launch the picker using:
startActivityForResult(Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) ,1);
and then acquire picture then in onActivityResult()
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
super.onActivityResult(requestCode, resultCode, intent)
val uri = intent!!.data!!
val inputStream = contentResolver.openInputStream(uri)!!
val bitmapBytes = inputStream.readBytes()
val bitmap = BitmapFactory.decodeByteArray(bitmapBytes, 0, bitmapBytes.size)
}
Question 1:
What permission are needed to produce Bitmap? I’m reading specs that READ_EXTERNAL_STORAGE would be needed. But code works without any permission in SDK 34-24, and starts only require READ_EXTERNAL_STORAGE on <= SDK 23.
Question 2:
Why I’m not needing READ_MEDIA_IMAGES on >= SDK 33? As it states on another specs, I would that permission to read images other app produced on SDK 33 onwards.
Question 3:
What would be advantage of using PhotoPicker API (instead MediaStore)?