Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

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

public class Main {
    /**
     * Indicates whether the specified action can be used as an intent example: isIntentAvailable(this,
     * "com.google.zxing.client.android.SCAN");
     *
     * @param pContext
     * @param pAction
     * @return
     */
    private static boolean isIntentAvailable(Context pContext, String pAction) {
        final PackageManager packageManager = pContext.getPackageManager();
        final Intent intent = new Intent(pAction);
        List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
        return list.size() > 0;
    }
}