get Package Activity Information via package name - Android Activity

Android examples for Activity:Activity Feature

Description

get Package Activity Information via package name

Demo Code


import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main{
    public static List<ActivityInfo> getPackageActivityInfo(
            Context mContext, String packageName) {
        List<ActivityInfo> packageActivityList = new ArrayList<ActivityInfo>();
        PackageInfo info = PackageInfoUtil.getPackageInfo(mContext,
                packageName, PackageManager.GET_ACTIVITIES);
        if (info != null && info.activities != null) {
            for (ActivityInfo af : info.activities) {
                packageActivityList.add(af);
            }//from   w  w w. ja v  a2 s. c  om
        }

        return packageActivityList;

    }
}

Related Tutorials