Recall & Review
beginner
What is the purpose of passing arguments between Android activities?
Passing arguments allows one activity to send data to another activity, enabling communication and data sharing between screens.
Click to reveal answer
beginner
How do you pass a simple string argument from one activity to another in Kotlin?
Use an Intent to start the new activity and add the string with putExtra(key, value). For example: intent.putExtra("username", "Alice").
Click to reveal answer
beginner
How do you retrieve a passed argument in the receiving activity?
In the receiving activity, use intent.getStringExtra(key) or the appropriate get method to get the data sent from the previous activity.
Click to reveal answer
intermediate
What is a Bundle in Android, and how is it related to passing arguments?
A Bundle is a container for key-value pairs used to pass data between activities or fragments. Intents use Bundles internally to carry extras.
Click to reveal answer
beginner
Why should you use constants for keys when passing arguments?
Using constants for keys avoids typos and makes code easier to maintain and understand, ensuring the same key is used when putting and getting data.
Click to reveal answer
Which method is used to add data to an Intent for passing arguments?
✗ Incorrect
putExtra() adds data to the Intent to pass it to another activity.
How do you retrieve a string argument named "user" in the receiving activity?
✗ Incorrect
getStringExtra("user") retrieves the string passed with the key "user".
What is the role of a Bundle in passing arguments?
✗ Incorrect
A Bundle holds data as key-value pairs to pass between activities or fragments.
Why is it recommended to use constants for keys when passing arguments?
✗ Incorrect
Constants prevent mistakes and ensure the same key is used everywhere.
Which of these is NOT a valid way to pass arguments in Android?
✗ Incorrect
SharedPreferences is for persistent storage, not for passing temporary arguments between activities.
Explain how to pass a string argument from one Android activity to another using Kotlin.
Think about how you send data with an Intent and retrieve it in the new screen.
You got /5 concepts.
Describe why using constants for keys when passing arguments is a good practice.
Consider what happens if you mistype a key in one place.
You got /4 concepts.