1

I have recently developed my second app. On clicking a specific button, I wish to open my first app. How do I do this?

I do know that I have to use Uri.parse, but how exactly do I use it?

4 Answers4

1

You will have to create an intent for that.As you know the package name you can create an intent as below and call startActivity

Intent launchIntent =  getPackageManager().getLaunchIntentForPackage("package.name");
startActivity(launchIntent);
Ajit Pratap Singh
  • 1,293
  • 12
  • 24
1

Try this:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(launchIntent);
Tran Vinh Quang
  • 625
  • 1
  • 9
  • 30
0

Try this SO question Open another application from your own (intent) found the below answer good enough

 public static boolean openApp(Context context, String packageName) {
        PackageManager manager = context.getPackageManager();
        try {
            Intent i = manager.getLaunchIntentForPackage(packageName);
            if (i == null) {
                return false;
                //throw new PackageManager.NameNotFoundException();
            }
            i.addCategory(Intent.CATEGORY_LAUNCHER);
            context.startActivity(i);
            return true;
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }
Community
  • 1
  • 1
Abx
  • 2,572
  • 3
  • 25
  • 47
0

if you want to open the other application you should know the package name of the launching app. try below code .

try {
    Intent intent = context.getPackageManager().getLaunchIntentForPackage("pakage name of application which you want to launch");
    if (intent ! = null) {
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    context.startActivity(intent);
   }
} catch (PackageManager.NameNotFoundException e) {

}
vishal jangid
  • 2,609
  • 14
  • 22