Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

import android.support.annotation.NonNull;

import java.util.List;

public class Main {
    /**
     * Returns true if the given intent can be handled on this device
     * @param context
     * @param intent
     * @return
     */
    public static boolean canHandleIntent(@NonNull Context context, Intent intent) {
        PackageManager packageManager = context.getPackageManager();
        List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return resolveInfo.size() > 0;
    }
}