Created
May 1, 2020 22:39
-
-
Save wajahatkarim3/118dc4eb039748ef5a4fe6ab0f6b2b61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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