nur atiqa
nur atiqa

Reputation: 33

How to launch another application from one application without installing

There is a button to launch other application inside my application and i use intent getpackagename. I manage to call and launch the other application but need to install the application inside phone before it can launch. Is there any other way to make the application launch without installing it or this seem impossible to do it?

Upvotes: 0

Views: 750

Answers (1)

Naresh NK
Naresh NK

Reputation: 1066

You can use this solution -

Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.myapp");

if(intent.resolveActivity(context.getPackageManager()) != null){  //Open app if installed
    startActivity(intent);
}else{//Send to play store to download or instant app solution
try {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.example.myapp")));
} catch (ActivityNotFoundException anfe) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.example.myapp")));
}
}

you can replace download from play store code with instant app launch code if that app supports it as @jake stated How to launch another application from one application without installing.

Upvotes: 1

Related Questions