Recipe 1.7 Calling Built-In Apps

Android Versions
Level 1 and above
Permissions
None
Source Code to Download at Wrox.com
CallingApps.zip

One of the key features of Android is the functionality it provides for applications to call other applications seamlessly. This enable you to integrate various applications on the device to form a coherent experience for your users. This recipe shows you the various ways to call the applications on your device.

Solution

There are many ways to call built-in apps, and how depends on which application you are calling. For this recipe’s solution, you will learn how to call some of the commonly installed applications on your Android device, such as:

  • How to display maps
  • How to direct the user to a particular application on Google Play
  • How to send e-mails
  • How to send text and graphic content to applications that can handle them

Displaying Maps

To display maps in your application, you can launch an activity using the geo: scheme, as shown in here:

package net.learn2develop.callingapps;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Intent i = new Intent(android.content.Intent.ACTION_VIEW);
        i.setData(Uri.parse("geo:37.827500,-122.481670"));
        startActivity(i);
    }

}

Figure 1-6 shows the application ...

Get Android Application Development Cookbook: 93 Recipes for Building Winning Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.