To check whether an app is installed in the device use following method and params
`GooglePlayStorePackageNameOld` & `GooglePlayStorePackageNameNew` both holds the package names of apps
private static final String GooglePlayStorePackageNameOld = "com.google.market";
private static final String GooglePlayStorePackageNameNew = "com.android.vending";
use and modify the following method accordingly to check if the app is presently installed in the device or not
public boolean isAppInstalled() {
PackageManager packageManager = getApplication().getPackageManager();
List<PackageInfo> packages = packageManager
.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
for (PackageInfo packageInfo : packages) {
if (packageInfo.packageName.equals(GooglePlayStorePackageNameOld)
|| packageInfo.packageName
.equals(GooglePlayStorePackageNameNew)) {
googlePlayStoreInstalled = true;
break;
} else {
googlePlayStoreInstalled = false;
}
}
return googlePlayStoreInstalled;
}
and to navigate user to a particular Play Store link use the following code
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
}
**EDIT**
According to your code
Intent LaunchIntent = getPackageManager()
.getLaunchIntentForPackage("com.Ch.Example.pack");
startActivity(LaunchIntent);
will launch the app which has the package name com.Ch.Example.pack
You can do this using the [`market://` prefix](https://developer.android.com/distribute/tools/promote/linking.html).
## Java
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
## Kotlin
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")))
} catch (e: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName")))
}
We use a `try/catch` block here because an `Exception` will be thrown if the Play Store is not installed on the target device.
**NOTE**: any app can register as capable of handling the `market://details?id=<appId>` Uri, if you want to specifically target Google Play check the *Berťák* answer