Android - How To Call or Invoke Built-in Apps

Android gives you the functionality which enables your application to call other applications seamlessly. This feature lets you integrate various other apps on the device to create a seamless experience for your app users. In this article we will show you the various ways to call the other apps like Maps, Playstore, Email, etc. on your device. There are various ways to call built-in apps and the method used to call these apps depends on which app you are calling. We will see how to call some of the commonly installed apps on your Android device.

Here we are assuming that the basic setup is done and the project structure is in place. We will just show the commands that should be used to invoke other apps.

Google Maps - To display Google maps we can launch an activity using the geo: scheme. Inside click event of a button use the following code

Uri uri = Uri.parse("geo:0,0?q=123 Custer Street, Piscataway, New Jersey");
Intent i = new Intent(Intent.ACTION_VIEW, uri);
if (mapIntent.resolveActivity(getPackageManager()) != null) {

If you have multiple Map apps are installed then an application chooser will launch from which you can choose whichever app you want maps to be displayed. To start the Google navigation, you may modify the above command as follows.

Uri uri = Uri.parse("google.navigation:q=123 Custer Street, Piscataway, New Jersey");
Intent i = new Intent(Intent.ACTION_VIEW, uri);
if (mapIntent.resolveActivity(getPackageManager()) != null) {

The navigation always starts from the current location of user. If you know the latitude and longitude then you can specify that in place of the complete address.

Google Play - If you want the user to download another application from Google Play or take him to your own app listing may be to collect ratings and feedback, you can use the market: scheme:

Intent i = new Intent(android.content.Intent.ACTION_VIEW);

Just change the package name with your own app package or any other package as you desire.

Send Email - To send an email from your app, we can invoke existing mailing apps like Gmail to perform this task. The code to do this activity is.

Intent i = new Intent(Intent.ACTION_SEND);
String[] to = { "" , "" };
String[] cc = { "" , "" };
i.putExtra(Intent.EXTRA_EMAIL, to);
i.putExtra(Intent.EXTRA_CC, cc);
i.putExtra(Intent.EXTRA_SUBJECT, "This is an important email");
i.putExtra(Intent.EXTRA_TEXT, "Message body");
startActivity(Intent.createChooser(i, "Email"));

You may also modify the above code to be able to launch the app chooser screen. Whichever app that is registered to handle ACTION_SEND will get listed in the chooser screen.

Intent i = new Intent(android.content.Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_SUBJECT, "Some Subject goes here");
i.putExtra(Intent.EXTRA_TEXT, "Some Message body goes here");
startActivity(Intent.createChooser(i, "Please select an App"));

Send Images - You can send images from your drawable folder or from local storage to other applications. This process is known as sending binary content to other apps.

Uri uri = Uri.parse("android.resource://com.youritbuddy.myapp/drawable/" + Integer.toString(R.drawable.myimage1));
Intent i = new Intent(android.content.Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_STREAM, uriToImage);
i.putExtra(Intent.EXTRA_TEXT, "Text...");
startActivity(Intent.createChooser(i, "Please select an App"));

The above code will select an image with the name myimage1.jpg from your drawable folder. To send multiple images, modify the code as follows.

Uri uri1 = Uri.parse("android.resource://com.youritbuddy.myapp/drawable/" + Integer.toString(R.drawable.myimage1));
Uri uri2 = Uri.parse("android.resource://com.youritbuddy.myapp/drawable/" + Integer.toString(R.drawable.myimage2));
ArrayList uris = new ArrayList();
Intent i = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
i.putExtra(Intent.EXTRA_STREAM, uris);
i.putExtra(Intent.EXTRA_TEXT, "Text...");
startActivity(Intent.createChooser(i, "Please select an App"));

If you want to send images stored locally on sdcard, modify the Uri code as follows.

Uri uri = Uri.parse("file:///storage/sdcard0/myimage1.jpg");

Just ensure that the above image files exist otherwise your App will crash unless proper exception handling is done.

Add comment