Code example for Context

Methods: getPackageManager

0
    public static boolean isIntentAvailable(Context context, String action, Uri uri, String mimeType) {
        final Intent intent = (uri != null) ? new Intent(action, uri) : new Intent(action);
        if (mimeType != null) {
            intent.setType(mimeType);
        } 
        List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return !list.isEmpty();
    } 
 
    /** 
     * Checks whether there are applications installed which are able to handle the given 
     * action/type. 
     *  
     * @param context 
     *            the current context 
     * @param action 
     *            the action to check 
     * @param mimeType 
     *            the MIME type of the content (may be null) 
     * @return true if there are apps which will respond to this action/type