Sobes.tech
Junior — Middle

Explain what an explicit intent means in Android and how it differs from an implicit one.

sobes.tech AI

Answer from AI

In Android, explicit intent is used to launch a specific component of the application, such as a particular Activity or Service, when the exact class name is known.

Implicit intent does not specify a particular component, but describes an action to be performed, and the system chooses an appropriate component capable of handling that 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);
intent.setData(Uri.parse("https://example.com"));
startActivity(intent);

In the first case, a specific Activity DetailActivity is launched, while in the second case, the system selects an application to view the URL.