문제

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.

도움이 되었습니까?

해결책

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) {
        e.printStackTrace();
        return null;
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top