Sobes.tech
Junior — Middle

Can you list the main types of intents in Android?

sobes.tech AI

Answer from AI

In Android, the main types of Intent:

  1. Explicit Intent — specifies a particular component (activity, service) to be started. Used when the exact class name is known.

  2. Implicit Intent — describes an action to perform without specifying a particular component. The system chooses an appropriate application to handle it.

  3. Broadcast Intent — used to send broadcast messages to the system or other applications.

  4. Service Intent — for starting or binding to a service.

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);