Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;
import android.content.Intent;

import android.content.pm.ResolveInfo;

import java.util.List;

public class Main {
    public static String getLActivityName(Context context) {
        Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> resolvInfos = context.getPackageManager().queryIntentActivities(intent, 0);

        String launcherActivityName = "";
        for (int i = 0; i < resolvInfos.size(); i++) {
            launcherActivityName = resolvInfos.get(i).activityInfo.name;
        }

        return launcherActivityName;
    }
}