Junior — Middle
Explain the concept of implicit Intent in the context of Android development.
sobes.tech AI
Answer from AI
In Android, implicit Intents are used to start components without specifying a particular class, but by action, category, or data type. This allows the system to choose the appropriate component to handle the request.
For example, if you want to open a web page, you can create an implicit Intent with the action ACTION_VIEW and a URI, and the system will prompt the user to select a browser or another app capable of handling this Intent.
Example of an implicit Intent to open a URL:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://example.com"));
startActivity(intent);
Thus, implicit Intents provide flexibility and interaction between applications without tight coupling to specific classes.