A intent is an abstract description of an action to be performed. Also known as a messaging component that is used to request certain action from another component.
Intents have basic fundamental use cases:
- To start an activity: Used to start new instance of an activity by passing intent to it.
ie. startActivity(new Intent(<CONTEXT_PACKAGE>, <CLASS>)).
Similarly, if we want to receive a result from the starting activity then we use startActivityForResult(<INTENT>, <RESULT_CODE>). - To start a service: Start a service to perform one time service by passing intent to startService(<INTENT>).
- To deliver a broadcast: Deliver broadcast to other apps by passing intent on functions such as sendBroadcast(<INTENT>). There are other ways to send broadcasts as well which will help differentiate what type of broadcast is being delivered. Learn more here.
Intent Types
There are two types of intents Continue reading