Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class SimpleContract : ActivityResultContract<Integer, String?>() {
override fun createIntent(context: Context, input: Integer?): Intent {
var intent = Intent(context, MyChildActivity::class.java)
intent.putExtra("myInputKey", input)
return intent
}
override fun parseResult(resultCode: Int, intent: Intent?): String? = when
{
resultCode != Activity.RESULT_OK -> null // Return null, if action is cancelled
else -> intent?.getStringExtra("data") // Return the data
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.