What is An Intent?

Asked 09-Jan-2018
Viewed 339 times

1 Answer


2

Intents are used to transfer asynchronous messages between the app and within the application.
You can use the intent in the following way in your app

Intnet intent = new Intent (getContext(), MyActivity.class);
startActivity(intent);
As soon as startActivity() method is called intent is passed to the sub-activity MyActivity.class. if you want to start the services via intent you can call startService(intent) method.
It can also be used to deliver the broadcast message.
There are two types of intents - 

1. Implicit Intent – These type of intent are used when you have to pass some information to other application like passing the URL to the YouTube app or giving the location to the Maps, etc.
2. Explicit Intent – These type of intent are used when you want to start the component or service within your app because you know the name of the activity or service you want to start.