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.Intent;

import android.content.pm.PackageManager;

import android.content.pm.ResolveInfo;

public class Main {
    public static ResolveInfo getResolveInfo(PackageManager pm, String packageName) {
        Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setPackage(packageName);
        List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
        if (apps != null && apps.size() > 0) {
            return apps.get(0);
        }
        return null;
    }
}