Here you can find the source of getFirstActivityName(Context context, String pkg)
public static String getFirstActivityName(Context context, String pkg)
//package com.java2s; import java.util.List; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.util.Log; public class Main { public static String getFirstActivityName(Context context, String pkg) { String activityName = null; List<PackageInfo> list = context.getPackageManager() .getInstalledPackages(PackageManager.GET_ACTIVITIES); int length = list.size(); Log.d("pkg length", length + ""); for (int i = 0; i < length; i++) { String name = list.get(i).packageName; Log.d("pkg " + i, name); if (name.equalsIgnoreCase(pkg)) { ActivityInfo activityinfo = list.get(i).activities[0]; activityName = activityinfo.name; Log.d("activity " + i, activityName); break; }/*from w w w . j a v a 2 s . c om*/ } return activityName; } }