Created
December 14, 2017 20:55
-
-
Save douglasiacovelli/2de02905e8520f94476b115f2401d390 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 FormActivity: AppCompatActivity { | |
onCreate(...){...} | |
fun sendFormAndGoBack(name: String) { | |
// if you want to send any type of data back, such as an object, string, int etc | |
// you have to create an intent and use this bit of code | |
// otherwise you can just use setResult(Activity.RESULT_OK) and finish() | |
val resultIntent = Intent() | |
resultIntent.putExtra(INPUT_NAME, name) | |
setResult(Activity.RESULT_OK, resultIntent) | |
finish() | |
} | |
companion object { | |
@JvmField | |
val INPUT_NAME = "com.example.app.INPUT_NAME" //this is basically a static field in java that can be accessed from other classes | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment