Open New Activity Using Intent: Kotlin
Intent facilitate communication between android application components in several ways, there are three fundamental use cases:
- Starting an Activity
- Starting an Service
- Delivering a Broadcast
In this article we are going to see how Intent is used for starting an Activity.
There are two types of Intent:
- Implicit Intent
- Explicit Intent.
Implicit intent: Implicit Intent is used to call Android built in activities like
- Camera
- Browser
- Gallery
- Dial/Call screen
Syntax:
Var i=Intent()
i.setAction(Intent.ACTION_NAME)
startActivity(i)
Explicit Intent: Explicit Intent is used for calling user generated Activities.
Syntax:
Var i=Intent(context, ActivityName::class.java)
startActivity(i)
Leave a Comment