Getting Installed App Size

Getting installed app size

Unfortunately there is currently no official way to do that. However, you can call the PackageManager's hidden getPackageSize method if you import the PackageStats and IPackageStatsObserver AIDLs into our project and generate the stubs. You can then use reflection to invoke getPackageSize:

PackageManager pm = getPackageManager();

Method getPackageSizeInfo = pm.getClass().getMethod(
"getPackageSizeInfo", String.class, IPackageStatsObserver.class);

getPackageSizeInfo.invoke(pm, "com.android.mms",
new IPackageStatsObserver.Stub() {

@Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)
throws RemoteException {

Log.i(TAG, "codeSize: " + pStats.codeSize);
}
});

That's obviously a big hack and should not be used for public applications.

  • Android Package Size
  • Using AIDL with Eclipse and ADT
  • APK Piracy: Using private code & resources in Android

find the APK size of installed applications

Here is a hack from Joseph that worked for me. His original post can be found here

PackageManager pm = getPackageManager();

Method getPackageSizeInfo = pm.getClass().getMethod(
"getPackageSizeInfo", String.class, IPackageStatsObserver.class);

getPackageSizeInfo.invoke(pm, "com.android.mms",
new IPackageStatsObserver.Stub() {

@Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)
throws RemoteException {

Log.i(TAG, "codeSize: " + pStats.codeSize);
}
});

Android, Get Installed App Size and Date

Ajay,

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.

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

Good luck!

How to get the size of installed application?

try this...

public static long getApkSize(Context context, String packageName)
throws NameNotFoundException {
return new File(context.getPackageManager().getApplicationInfo(
packageName, 0).publicSourceDir).length();
}

How to get size of installed apps on device using Flutter?

It's not possible with device_apps library.

You can request this feature posting an issue on https://github.com/g123k/flutter_plugin_device_apps/issues and wait an answer from contributors

Or

Create a pull request and implement this feature by yourself ;)



Related Topics



Leave a reply



Submit