In Android, an Intent is a software mechanism for describing an operation to be performed. It's a fundamental concept that facilitates communication between components such as activities, services, and broadcast receivers.
An Intent can be explicit, where you specify the component to start by name, or implicit, where you declare a general action to perform and the system finds an appropriate component for you.
Here's a simple example of explicit intent:
Intent intent = new Intent(this, TargetActivity.class);
startActivity(intent);
And an example of an implicit intent:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
startActivity(intent);
Remember: Always declare intent filters for your components in the manifest if you want them to respond to implicit intents!
No comments:
Post a Comment