Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Zheng Sun.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Zheng Sun - initial API and implementation
 ******************************************************************************/

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 {
    public static boolean isIntentAvailable(final Context context, final String className) {
        final PackageManager packageManager = context.getPackageManager();
        final Intent intent = new Intent(className);
        final List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return (list.size() > 0);
    }
}