Created
November 28, 2013 16:16
-
-
Save dominicthomas/7694379 to your computer and use it in GitHub Desktop.
Launch another app using an intent with package name if app has a launcher activity or using package name and class name of main activity.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only works if app has a launcher activity | |
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.example.yourapp"); | |
startActivity(launchIntent); | |
// works if we know the name of the main activity, even if not a launcher | |
Intent intent = new Intent(Intent.ACTION_MAIN); | |
intent.setClassName("com.example.yourapp", "com.example.yourapp.MainActivity"); | |
startActivity(intent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you made my day @dominicthomas !! thx for sharing this..
only change needed for me was using
context.startActivity(intent);
instead ofstartActivity(intent);
(Android14)