Bharath Kumar Bachina Bharath Kumar Bachina - 1 year ago 88
Android Question

Get All Activities by using package Name

I want to get all activities present in Application as a list by using PackageInfo. Please tell me is there any way to do this.

Thanks in advance.

Answer Source

I got answer to my question as follows.

public static ArrayList<ActivityInfo> getAllRunningActivities(Context context) {
    try {
        PackageInfo pi = context.getPackageManager().getPackageInfo(
                context.getPackageName(), PackageManager.GET_ACTIVITIES);

        return new ArrayList<>(Arrays.asList(pi.activities));

    } catch (PackageManager.NameNotFoundException e) {
        return null;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download