In Android, the Intent
class is used to perform various actions, such as launching an activity, starting a service, delivering a broadcast, and more. You can use an Intent
to launch a web browser to a specific URL, dial a phone number, or send an email, among other things.
Here are some examples of how to use the Intent
class to perform these actions:
String url = "https://www.example.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i);
String phoneNumber = "1234567890"; Intent i = new Intent(Intent.ACTION_DIAL); i.setData(Uri.parse("tel:" + phoneNumber)); startActivity(i);
String email = "example@example.com"; Intent i = new Intent(Intent.ACTION_SENDTO); i.setData(Uri.parse("mailto:" + email)); i.putExtra(Intent.EXTRA_SUBJECT, "subject"); i.putExtra(Intent.EXTRA_TEXT, "body"); startActivity(i);
For more information on the Intent
class in Android, you can refer to the Android documentation.