would it be possible, to start activity for result (e.g. select file), if you only have context. I have a wild idea of making interactor/usecase that does that. Any ideas?
Copy code
class SelectFileUseCase @Inject constructor(
@ApplicationContext private val context: Context
) {
operator fun invoke(): Uri {
val intent = Intent().apply {
type = "file/*"
action = Intent.ACTION_GET_CONTENT
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
context.startActivity(intent)
// how to get result??
context.registerReceiver(receiver, filter) // maybe?
}
}
a
Adam Powell
07/08/2021, 7:04 PM
Nope, an activity started for result needs an activity to return the result to
p
Peter Mandeljc
07/08/2021, 7:07 PM
bummer. Thanks!
i
Ian Lake
07/08/2021, 8:40 PM
That being said, you absolutely can push all of the intent handling out into your own, separately testable class if you're using the