如何在Android设备中获取已安装应用程序的大小?

时间:2017-01-17 06:56:59

标签: java android xml get size

public void getAppSize(ArrayList<ApplicationInfo> data) {
        for (int m = 0; m < data.size(); m++) {
            packageManager = getPackageManager();
            Method getPackageSizeInfo;

            try {
                 getPackageSizeInfo =  packageManager.getClass().getMethod("getPackageSizeInfo", String.class, IPackagestatsObserver.class);
                if (getPackageSizeInfo != null) {
                    try {
                        getPackageSizeInfo.invoke(packageManager, data.get(m).packageName, new cachePackState());
                    } catch (IllegalAccessException | InvocationTargetException e) {
                        e.printStackTrace();
                    }
                }
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }

        }
    }

0 个答案:

没有答案