Skip to content

Instantly share code, notes, and snippets.

@surajsau
Created February 5, 2020 10:13
Show Gist options
  • Save surajsau/0f63fcc345ddb2ce3fdc44ee93526f7e to your computer and use it in GitHub Desktop.
Save surajsau/0f63fcc345ddb2ce3fdc44ee93526f7e to your computer and use it in GitHub Desktop.
Flow 1: Complete flow in MCQ
class A: AppCompatActivity() {
..
fun startB() {
..
startActivityForResult(intent, REQ_CODE)
}
override onActivityResult(intent, reqCode, ..) {
if(reqCode == REQ_CODE) {
when(intent.getString("source")) {
"B" -> btn.text = "Continute"
"D" -> btn.text = "Review"
}
}
}
}
class B: AppCompatActivity() {
..
fun startC() {
..
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
startActivity(intent, REQ_CODE)
}
}
class C: AppCompatActivity() {
..
fun startD() {
..
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
startActivity(intent, REQ_CODE)
}
}
class D: AppCompatActivity() {
..
fun clickBack() {
..
intent.put("source", "D")
setResult(RESULT_OK, intent)
finish()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment