Open external Android app from within Android app

You can open any external Android application from within your Android application by pressing a button (or any other event). All you need to know is the namespace of the application you want to launch.

For this functionality use following code snippet:

public class MainActivity extends Activity {

private Button openAppButton;

protected void onCreate(Bundle savedInstanceState) {

openAppButton = (Button) findViewById(;
openAppButton.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {

Intent i = new Intent();
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("");



In this code replace „“ with the namespace of the app you want to launch. If you don’t know the namespace of the app you can go to Google Play and search for the app. Inside the URL the namespace is mentioned as the „id“. For example, Google Maps has following URL:

As you can see, the value of id is „“ – this is the app’s namespace.