Intents and Navigation
What is an Intent?
An Intent is a message that says “do this”. You use it to open another screen, share text, open a URL, or start a phone call.
Open another screen (explicit intent)
val intent = Intent(this, ProfileActivity::class.java)
intent.putExtra("userId", 42) // pass data
startActivity(intent)
Read the data on the other screen:
val userId = intent.getIntExtra("userId", 0)
Ask the system to do something (implicit intent)
val web = Intent(Intent.ACTION_VIEW, Uri.parse("https://aimobilecoders.com"))
startActivity(web)
Modern tip: For bigger apps use the Navigation Component or Jetpack Compose navigation instead of manually juggling many activities.