Google News
logo
Android - Interview Questions
What is the difference between an implicit intent and explicit intent?
Implicit Intent is used whenever you are performing an action. For example, send email, SMS, dial number or you can use a Uri to specify the data type.

For example :
Intent i = new Intent(ACTION_VIEW,Uri.parse("https://www.freetimelearning.com")); 
startActivity(i);

 

Explicit, on the other hand, helps you to switch from one activity to another activity(often known as the target activity). It is also used to pass data using putExtra method and retrieved by other activity by getIntent().getExtras() methods.
 
For example : 
Intent i = new Intent(this, Activitytwo.class); #ActivityTwo is the target component
i.putExtra("Value1","This is ActivityTwo"); 
i.putExtra("Value2","This Value two for ActivityTwo"); 
startactivity(i);

 

Advertisement