What is An Intent?

1 votes
136 views
Harsh kumar srivastava asked 09-Jan-2018 in Technology by Harsh kumar srivastava

What is An Intent?

1 Answer

2 votes
Prateek sharma answered 10-Jan-2018 by Prateek sharma
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.