Android Context Check isAppInstalled(Context context, String uri)

Here you can find the source of isAppInstalled(Context context, String uri)

Description

Check if package installed

License

Open Source License

Parameter

Parameter Description
context Context of current app
uri Package of application to check

Return

true if passed package installed

Declaration

public static boolean isAppInstalled(Context context, String uri) 

Method Source Code

//package com.java2s;
//  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of

import android.content.Context;

import android.content.pm.PackageManager;

public class Main {
    /**/*www  . j  a  va2 s  .  co m*/
     * Check if package installed
     *
     * @param context Context of current app
     * @param uri Package of application to check
     * @return true if passed package installed
     */
    public static boolean isAppInstalled(Context context, String uri) {
        PackageManager pm = context.getPackageManager();
        boolean appInstalled;
        try {
            assert pm != null;
            pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
            appInstalled = true;
        } catch (PackageManager.NameNotFoundException e) {
            appInstalled = false;
        }
        return appInstalled;
    }
}

Related

  1. hasTelephony(@Nonnull Context context)
  2. hasVibrationPermission(Context context)
  3. is3G(Context context)
  4. isAccessibilityEnabled(Context context, String id)
  5. isAppInstalled(Context context)
  6. isAppOnForeground(Context context)
  7. isApplicationBroughtToBackground( final Context context)
  8. isApplicationBroughtToBackground( final Context context)
  9. isCallable(Context context, String url)