get Start Activity - Android Activity

Android examples for Activity:Activity Start

Description

get Start Activity

Demo Code


//package com.java2s;
import java.util.List;

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

public class Main {
    public static String getStartActivity(Context cxt, String packName) {

        Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
        resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        resolveIntent.setPackage(packName);

        List<ResolveInfo> resolveinfoList = cxt.getPackageManager()
                .queryIntentActivities(resolveIntent, 0);

        if (resolveinfoList != null && !resolveinfoList.isEmpty()) {
            ResolveInfo resolveinfo = resolveinfoList.get(0);
            if (resolveinfo != null) {
                return resolveinfo.activityInfo.name;
            }/*from w  w  w.  j  a  v  a2 s  .  c  om*/
        }
        return null;
    }
}

Related Tutorials