How to implement it so that when you click on the button, the application checks whether another application is installed and, if it exists, launch it. Otherwise open the page, for example google play.

    1 answer 1

    Check for the presence of the application can be done as follows :

    public static boolean isAppInstalled(Context context, String packageName) { try { context.getPackageManager().getApplicationInfo(packageName, 0); return true; } catch (PackageManager.NameNotFoundException e) { return false; } } 

    To run the application, you can use the getLaunchIntentForPackage (String packageName) .

    And you can open the application on Google Play as follows :

     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))); }