CS4521:   Mobile and Topics in Web Programming

Using Intents to call Built-in Apps

See example in Books/Android/Source Code/Intents

Intent i = new Intent(android.content.Intent.ACTION_VIEW); ///specifies the viewer (web browser) built-in app

Intent i = new Intent(android.content.Intent.ACTION_DIAL); //specifies phone built-in app

      • android.content.Intent.ACTION_VIEW //view some data passed
      • android.content.Intent.ACTION_DIAL //show phone dialer
      • android.content.Intent.EDIT //edit data passed
      • android.content.Intent.ACTION_PICK //contacts database
      • SEE API FOR android.content.Intent.* options!!!

 

Some Examples:

  • Intent i = new Intent(android.content.Intent.ACTION_DIAL, Uri.parse("tel:+5101234567"));
  • Intent i = new Intent(android.content.Intent.ACTION_CALL, Uri.parse("tel:+5101234567")); //if add permission to application manifest "android.permission.CALL_PHONE" will dial automatically without user prompting.
  • Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:37.8270,-122.48")); //lat and long of map

Intent i = new Intent(andriod.content.Intent.ACTION_VIEW, Uri.parse("http://amazon.com"));
startActivity();

browser

 

 

Intent i = new Intent(android.content.Intent.ACTION_DIAL, Uri.parse("tel:+651234567"));
startActivity();

dialer

 

Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:37.8270,-122.48"));
startActivity();

MUST RUN AGAINST AND AVD WITH GOOGLE API NOT JUST standard android sdk

built in map

 

 

 

One More THING --- Intent Resolution

When you have an Intent and you say you want a built-in application it will look for any Activity that is available that has this feature...and if you use Intent.createChooser(i, "string") it will give the user all the available ptions to select.

Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://www.amazon.com"));
startActivity(Intent.createChooser(i, "Complete action using.....");

 

multiple choices

 

 

© Lynne Grewe