Friday, 21 August 2015

What is implicit intent in android?

Implicit intent is used to invoke the system components.

Implicit Intent doesn't specify the component. In such case, intent provides information of available components provided by the system that is to be invoked.

For example, you may write the following code to view the webpage.

Intent intent=new Intent(Intent.ACTION_VIEW);  
intent.setData(Uri.parse("http://www.google.com"));  
startActivity(intent);  


Implicit Android Intents is the intent where instead of defining the exact components, you define the action you want to perform. 
The decision to handle this action is left to the operating system. The OS decides which component is best to run for implicit intents.

Let us see an example:

    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);


This is a simple example of an share Android Intent. This is typically used when you want to share the data from 1 application to another. Sharing data over email, sms, social network etc. is a classic example of this category. See the image below, this is a implicit intent for sending email.


No comments:

Post a Comment