You have created a NextActivity class that relies on a string containing some data that pass inside the intent Which code snippet allows you to launch your activity?

✅  The correct answer is:

  • Intent(this, NextActivity::class.java).apply {
    putExtra(EXTRA_NEXT, “some data”)
    }.also { intent ->
    startActivity(intent)
    }

Question:

You have created a NextActivity class that relies on a string containing some data that pass inside the intent Which code snippet allows you to launch your activity?

Solution:

  • Intent(this, NextActivity::class.java).also { intent ->
    startActivity(intent)
    }
  • Intent(this, NextActivity::class.java).apply {
    put(EXTRA_NEXT, “some data”)
    }.also { intent ->
    activityStart(intent)
    }
  • Intent(this, NextActivity::class.java).apply {
    putExtra(EXTRA_NEXT, “some data”)
    }.also { intent ->
    startActivity(intent)
    }
  • Intent(this, NextActivity::class.java).apply {
    put(EXTRA_NEXT, “some data”)
    }.also { intent ->
    activityStart(intent)
    }