- Dial Action: dial a number
- Airplane mode action
- View action: launch browser, show location, play music
- Send to action: send email, text message,
- Pick action: image, contact
- etc
Typically implicit activities are used to launch activities outside of your package, but they can also launch activities inside your package. Implicit intents require several things to accomplish their task:
- Action: the thing you want done
- Data: the data you want passed to the activity
- MIME Type: they type of information ART is going to have to operate on
- Categories: Style of activity you want
- Extras: more data to operate on
Not every field above is required, often times action and data are all you need.
Some actions are obvious as to which activity a user needs, for example the DialAction or ActionImageCapture, however others like the ViewAction are not and need a piece of data to help art route them appropriately.
Taking a photo
private void
PhotoButton_Click(object sender,
EventArgs e)
{
var intent = new
Intent();
intent.SetAction(MediaStore.ActionImageCapture);
if (intent.ResolveActivity(PackageManager) != null)
base.StartActivity(intent);
}
Showing a location is a dad more complicated.
private void
GeoButton_Click(object sender,
EventArgs e)
{
var intent = new
Intent();
intent.SetAction(Intent.ActionView);
intent.SetData(Android.Net.Uri.Parse("geo:46.5215962,6.6380333?z=17"));
if (intent.ResolveActivity(PackageManager) != null)
base.StartActivity(intent);
}
Calling a phone
private void
PhoneButton_Click(object sender,
EventArgs e)
{
var intent = new
Intent();
intent.SetData(Android.Net.Uri.Parse("tel:(855) 926-2746"));
if (intent.ResolveActivity(PackageManager) != null)
base.StartActivity(intent);
}
again a simple action that all it needs is the data, the tel protocol lets ART know you want a dialer.
Sending an email
private void
EmailButton_Click(object sender,
EventArgs e)
{
var intent = new
Intent();
intent.SetAction(Intent.ActionSendto);
if (intent.ResolveActivity(PackageManager) != null)
{
intent.SetData(Android.Net.Uri.Parse("mailto:"));
intent.PutExtra(Intent.ExtraEmail, new[] { "pawel.ciucias@fake.com" });
intent.PutExtra(Intent.ExtraSubject, "Heyoh!!");
base.StartActivity(intent);
}
}