获取所有的acvivity

2017-02-07 16:58
/**
     * Get target package activities.
     * @param context context
     * @return activities
     */
    public ActivityInfo[] getAllActivities(Context context){
        try {
            PackageManager pm = context.getPackageManager();
            PackageInfo info = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES);
            return info.activities;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }