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 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 void startIntent(Context context, Intent intent) {
        boolean b = isIntentExist(context, intent);
        if (b) {
            context.startActivity(intent);
        }
    }

    public static boolean isIntentExist(Context context, Intent intent) {
        List<ResolveInfo> localList = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.GET_INTENT_FILTERS);
        if ((localList != null) && (localList.size() > 0)) {
            return true;
        } else {
            return false;
        }
    }
}