Question
How to Launch an Activity from Another App in Android Using Intents
Question
I want to launch an installed application package from my Android app. I assume this is possible using Android intents, but I have not found a clear way to do it. How can I open another installed app, or one of its activities, from my application? Is there official guidance or a standard approach for this?
Short Answer
By the end of this page, you will understand how Android apps can start activities in other apps using Intent objects. You will learn the difference between launching an app normally versus targeting a specific activity, how to use PackageManager, how to check whether the target app exists, and how to avoid common errors such as ActivityNotFoundException.
Concept
In Android, apps do not usually call each other directly. Instead, they communicate through a messaging system built around intents.
An Intent describes an action to perform, such as:
- opening a screen
- sharing data
- viewing a web page
- launching another app
When you want to start an activity from another application, you usually do one of these:
- Launch the app's main entry activity using its package name
- Launch a specific exported activity using an explicit intent
- Ask Android to find a matching activity using an implicit intent
This matters because Android apps are sandboxed. One app cannot freely access another app's internal classes or screens unless that screen is exposed in the target app's manifest.
Two common ways to launch another app
1. Launch the app normally
If you only want to open another installed app, the standard approach is:
- get the launch intent for the package
- check if it exists
- call
startActivity()
This is the safest and most common method.
2. Launch a specific activity
If you know the exact package name and activity class name, you can build an explicit intent with setClassName() or ComponentName.
This only works if:
- the activity exists
- the activity is exported or otherwise accessible
- your app has any required permissions
Why this concept matters
This pattern is used in many Android apps for:
- opening map apps
Mental Model
Think of an Android Intent like a delivery note.
- The package name is the building address.
- The activity name is the specific room inside the building.
- Android is the courier that decides where the message goes.
If you only provide the building address, Android can open the main entrance of that app. If you provide both the building and the room, Android tries to open that exact screen. If the building does not exist, or the room is private, the delivery fails.
So launching another app is not about calling its code directly. It is about sending Android a properly addressed request.
Syntax and Examples
Launch another installed app by package name
This is the most common approach.
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.example.otherapp");
if (launchIntent != null) {
startActivity(launchIntent);
} else {
// App is not installed
}
How it works
getPackageManager()gives access to information about installed appsgetLaunchIntentForPackage(...)asks Android for the app's main launch activity- if it returns
null, the app is not installed or has no launchable activity
Launch a specific activity in another app
Intent intent = new Intent();
intent.setClassName(
"com.example.otherapp",
"com.example.otherapp.MainActivity"
);
startActivity(intent);
Important
This works only if that activity is accessible from your app.
Safer version with error handling
Step by Step Execution
Consider this example:
String packageName = "com.example.otherapp";
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(packageName);
if (launchIntent != null) {
startActivity(launchIntent);
}
Step by step
1. Store the target package name
String packageName = "com.example.otherapp";
This is the unique identifier of the installed app you want to open.
2. Ask Android for that app's launch intent
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(packageName);
Android looks for the main launcher activity of that package.
Possible results:
- returns an
Intentif the app is installed and launchable - returns
nullif the package is missing or has no launcher activity
3. Check whether the intent exists
Real World Use Cases
Common practical uses
Open a companion app
A wearable app may open its paired phone app.
Launch navigation or map apps
Your app may send the user to Google Maps or another navigation app.
Start a payment or wallet app
A shopping app may redirect the user to an installed payment provider.
Open messaging or email apps
You may launch another app to continue an action there.
Enterprise and kiosk workflows
A company device may move users between approved internal apps.
Examples in real apps
- A banking app opening a trusted authentication app
- A store app opening a delivery partner app
- A file app opening a PDF viewer
- A launcher app opening installed apps by package name
- A support app opening device settings or system screens
Real Codebase Usage
In real Android projects, developers usually do more than just call startActivity().
Common patterns
Guard clause for missing app
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.otherapp");
if (intent == null) {
return;
}
startActivity(intent);
This is a simple guard clause: exit early if the app cannot be launched.
Show a fallback message or store link
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.otherapp");
if (intent != null) {
startActivity(intent);
} else {
Toast.makeText(this, "Please install the app first", Toast.LENGTH_LONG).show();
}
In production, many apps also redirect users to Google Play.
Centralize app-launch logic
Large projects often keep this logic in a helper method:
public void openApp(String packageName) {
getPackageManager().getLaunchIntentForPackage(packageName);
(intent != ) {
startActivity(intent);
}
}
Common Mistakes
1. Starting an app without checking for null
Broken code:
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.otherapp");
startActivity(intent);
Problem:
- if the app is not installed,
intentisnull - this can cause a crash
Fix:
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.otherapp");
if (intent != null) {
startActivity(intent);
}
2. Confusing package name with activity name
Broken code:
intent.setClassName("com.example.otherapp.MainActivity", "com.example.otherapp");
Problem:
- the first value should be the package
- the second value should be the full activity class name
Fix:
intent.setClassName(, );
Comparisons
| Approach | What it does | Best for | Limitations |
|---|---|---|---|
getLaunchIntentForPackage() | Opens the app's main launch activity | Opening another app normally | Requires a launchable activity |
setClassName() / explicit intent | Opens a specific activity in another app | Known public activity entry points | Fails if activity is private, missing, or renamed |
| Implicit intent | Lets Android find a matching app/activity | Standard actions like view, share, dial | Less control over exact target |
Explicit intent vs implicit intent
| Type | You specify | Example |
|---|---|---|
| Explicit intent |
Cheat Sheet
Quick reference
Launch another app
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.otherapp");
if (intent != null) {
startActivity(intent);
}
Launch a specific activity
Intent intent = new Intent();
intent.setClassName("com.example.otherapp", "com.example.otherapp.MainActivity");
startActivity(intent);
Safe version with try/catch
try {
Intent intent = new Intent();
intent.setClassName("com.example.otherapp", "com.example.otherapp.MainActivity");
startActivity(intent);
} catch (ActivityNotFoundException e) {
// handle error
}
Rules to remember
- Use
PackageManagerto find launch intents - Check for
nullbefore calling
FAQ
How do I open another installed app in Android?
Use getPackageManager().getLaunchIntentForPackage(packageName) and call startActivity() if the result is not null.
Can I open a specific activity from another app?
Yes, with an explicit intent such as setClassName(), but only if that activity is accessible and exported.
What happens if the target app is not installed?
getLaunchIntentForPackage() usually returns null, so you should check before starting the activity.
Why does ActivityNotFoundException happen?
It happens when Android cannot find the activity you requested, or your app is not allowed to open it.
Is using intents the standard way to launch another app?
Yes. Intents are the standard Android mechanism for requesting actions across apps.
Do I need permissions to launch another app?
Usually not for a normal launch intent, but some specific activities or integrations may require permissions.
Can every activity in another app be launched externally?
No. Only activities exposed by that app and allowed by Android's security rules can be launched.
Where can I find official Android information?
The official Android documentation for Intent, , and activity launching is the right place to start.
Mini Project
Description
Build a small Android screen with a button that tries to open another installed app by package name. If the app is unavailable, show a message instead. This demonstrates the safest beginner-friendly pattern for launching external apps.
Goal
Create an Android activity that opens another app if it is installed and handles the missing-app case without crashing.
Requirements
- Create a button in an Android activity
- When the button is tapped, try to open an app using its package name
- Check whether a launch intent exists before calling
startActivity() - Show a toast message if the app is not installed
Keep learning
Related questions
Android AlarmManager Example: Scheduling Tasks with AlarmManager
Learn how to use Android AlarmManager to schedule tasks, set alarms, and handle broadcasts with a simple beginner example.
Can You Extend a Data Class in Kotlin? Inheritance, Limits, and Better Alternatives
Learn why Kotlin data classes cannot be extended, what causes the component function clash, and which alternatives to use instead.
Difference Between List and Array in Kotlin
Learn the difference between List and Array in Kotlin, including mutability, size, APIs, performance, and when to use each one.