Код: Выделить всё
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result ->
if (result.resultCode == RESULT_OK) {
result.data?.getStringExtra(EXTRA_RENAME)?.let {
Код: Выделить всё
val intentSender = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> {
MediaStore.createWriteRequest(
context.contentResolver,
listOf(it)
).intentSender
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> {
val recoverableSecurityException = e as? RecoverableSecurityException
recoverableSecurityException?.userAction?.actionIntent?.intentSender
}
else -> null
}
intentSender?.let { sender ->
val intent = Intent().apply {
Bundle().also { extras ->
extras.putString(EXTRA_RENAME, newName)
putExtras(extras)
}
}
launcher?.launch(IntentSenderRequest.Builder(sender).setFillInIntent(intent).build())
}
Я уверен, что функция регистрации была запущена снова, но данные всегда имеют значение NULL.
Подробнее здесь: https://stackoverflow.com/questions/788 ... rforresult
Мобильная версия