Activity callback method

Hits: 0

  1. The jump method in the current Activity is used:


  1. Return to the current Activity in the target Activity:

val  intent : Intent = Intent()
    finishSelfWithResult(intent, "numCommand" to command.isState, "flag" to "1")

//If the target activity is in the form of a pop-up window, then when finishSelfWithResult is used, the Activity will automatically exit after clicking.

  1. Receive and process data in the current Activity:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (resultCode == Activity.RESULT_OK) {            //Determine the return code 
        when (requestCode) {                           //Determine the request code 
            10 -> {
                data?.let {
                    numOrder = it.getIntExtra("numCommand", -2)
    } else if (resultCode == Activity.RESULT_CANCELED) {


// requestCode : The request code, defined in the class. to any value. 
// resultCode: Return code: usually OK / CANCEL to indicate success/failure

You may also like...

Leave a Reply

Your email address will not be published.