Sobes.tech
Junior — Middle

How to distinguish explicit Intent from implicit in Android development?

sobes.tech AI

Answer from AI

In Android development, an Intent is an object that describes an action to be performed. There are two types of Intents:

  • Explicit Intent — specifies a particular component (such as an Activity or Service) by name. It is used when you know exactly which component you want to start.

  • Implicit Intent — does not specify a particular component, but describes the action to be performed (such as opening a web page or making a call). The system chooses the appropriate component that can handle this Intent.

Example of an explicit Intent:

Intent intent = new Intent(this, DetailActivity.class);
startActivity(intent);

Example of an implicit Intent:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://example.com"));
startActivity(intent);

Thus, an explicit Intent specifies a particular class, while an implicit Intent only specifies the action and data.