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

import java.util.List;

public class Main {

    public static boolean isLauncherActivity(Context context, String packageName) {
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        mainIntent.setPackage(packageName);
        List<ResolveInfo> infoList = context.getPackageManager().queryIntentActivities(mainIntent, 0);
        if (infoList.isEmpty()) {
            return false;
        } else {
            return true;
        }
    }
}