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:
-
Explicit Intent — specifies a particular component (activity, service) to be started. Used when the exact class name is known.
-
Implicit Intent — describes an action to perform without specifying a particular component. The system chooses an appropriate application to handle it.
-
Broadcast Intent — used to send broadcast messages to the system or other applications.
-
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);