hesam
12/12/2019, 10:10 PM[<content://com.android.providers.media.documents/document/image%3A38>]
However, when I take a photo and store it in MediaStore.Images, then its uri looks like this: [<content://media/external/images/media/51>]
. Is there anyway that I get a uri like the first uri? [code in the comment]hesam
12/12/2019, 10:10 PMfun dispatchTakePictureIntent(activity: Activity) {
Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent ->
val camIntent = takePictureIntent.resolveActivity(activity.packageManager)
camIntent?.also {
val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CANADA).format(Date())
val values = ContentValues()
values.put(MediaStore.Images.Media.TITLE, "ATCO - $timeStamp")
values.put(MediaStore.Images.Media.DESCRIPTION, "Deficiency picture.")
activity.contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values)?.let {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, it)
activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE_CAPTURE)
}
}
}
}
hesam
12/12/2019, 11:22 PMval path = if (stringUri.contains("com.android.providers")) stringUri else {
val fileName: String = stringUri.substring(stringUri.lastIndexOf("/") + 1, stringUri.length)
"<content://com.android.providers.media.documents/document/image:$fileName>"
}
Aslam Hossin
12/18/2019, 2:49 AMintent
based on your application id file provider.