adding an extra result intent flag

This commit is contained in:
tibbi 2018-10-23 16:04:49 +02:00
parent e9afd1c41b
commit 6bce8b7c25
1 changed files with 11 additions and 8 deletions

View File

@ -306,13 +306,14 @@ class MainActivity : SimpleActivity() {
} }
fun pickedRingtone(path: String) { fun pickedRingtone(path: String) {
val resultIntent = Intent()
val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID) val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID)
val type = path.getMimeType() val type = path.getMimeType()
resultIntent.setDataAndType(uri, type) Intent().apply {
resultIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION setDataAndType(uri, type)
resultIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, uri) flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
setResult(Activity.RESULT_OK, resultIntent) putExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, uri)
setResult(Activity.RESULT_OK, this)
}
finish() finish()
} }
@ -324,9 +325,11 @@ class MainActivity : SimpleActivity() {
clipData.addItem(ClipData.Item(it)) clipData.addItem(ClipData.Item(it))
} }
val resultIntent = Intent() Intent().apply {
resultIntent.clipData = clipData this.clipData = clipData
setResult(Activity.RESULT_OK, resultIntent) flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
setResult(Activity.RESULT_OK, this)
}
finish() finish()
} }