Android Intent Check isIntentAvailable(Context context, String action)

Here you can find the source of isIntentAvailable(Context context, String action)

Description

Check if action available installed

License

Open Source License

Parameter

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

Return

true if passed package installed

Declaration

public static boolean isIntentAvailable(Context context, String action) 

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.Intent;

import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import java.util.List;

public class Main {
    /**/*from   w  w w .  j  a  v  a2 s .c om*/
     * Check if action available installed
     *
     * @param context Context of current app
     * @param action Package of application to check
     * @return true if passed package installed
     */
    public static boolean isIntentAvailable(Context context, String action) {
        final PackageManager packageManager = context.getPackageManager();
        final Intent intent = new Intent(action);
        assert packageManager != null;
        List<ResolveInfo> list = packageManager.queryIntentActivities(
                intent, PackageManager.MATCH_DEFAULT_ONLY);
        return list.size() > 0;
    }
}

Related

  1. isCallable(Context c, Intent intent)
  2. isCommonIntentUrl(String url)
  3. isIntentAvailable(final Context context, final String action)
  4. isIntentUrl(String url)
  5. isPlayMarketIntentUrl(String url)
  6. isIntentAvailable(@Nonnull Context context, @Nonnull String action)