Method to get weather the intent is available in system to perform specified operation - Android Intent

Android examples for Intent:Open App

Description

Method to get weather the intent is available in system to perform specified operation

Demo Code


//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 {
    /**/*from  w ww .  ja v a  2s . c om*/
     * Method to get weather the intent is available in system to perform
     * specified operation
     * 
     * @param ctx
     * @param in
     * @return
     */
    private static boolean isIntentAvailable(Context ctx, Intent in) {
        PackageManager packageManager = ctx.getPackageManager();
        List<ResolveInfo> activities = packageManager
                .queryIntentActivities(in, 0);
        return (activities == null) ? false : (activities.size() > 0);
    }
}

Related Tutorials