安卓,获取安装的应用程序的大小和日期应用程序、大小、日期

2023-09-05 07:16:17 作者:醒在丶深海里的猫

在Android的,我怎样才能获得应用程序安装日期,我怎么可以得到安装的应用程序的大小。

In Android, How I can get app installed date and how I can get installed app size.

我使用下面code让应用程序的大小,但它是不正确的。

I am using below code to get app size but it is not correct

清单包= getPackageManager()getInstalledPackages(0);。

List packs = getPackageManager().getInstalledPackages(0);

for(i=0;i<packs.size();i++) {
    PackageInfo p = packs.get(i);
    ApplicationInfo appInfo =p.applicationInfo;
    long fileSize = new FileInputStream(appInfo.sourceDir).getChannel().size();
}

请帮我.. 谢谢你,

推荐答案

阿贾伊,

要得到你将要使用的PackageManager类。更具体地,getPackageInfo()方法。这会回报给你一个PackageInfo对象,它包含firstInstallTime值。

To get the installation date you will want to use the PackageManager class. More specifically the getPackageInfo() method. This will return to you a PackageInfo object which contains firstInstallTime value.

还有目前不存在一个公共API来获取应用程序的大小 PackageManager.getpackageSizeInfo()是从SDK 0.9的API拆下来SDK 1.0。请参阅HERE

There does not currently exist a public API to get an application's size as PackageManager.getpackageSizeInfo() was removed from the API from SDK 0.9 to SDK 1.0. See HERE

祝你好运!