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
Listview with Onitemclicklistener
How to Set Android Layout to Support All Screen Sizes
How to Apply a Style to All Buttons of an Android Application
How to Enable Tls 1.2 Support in an Android Application (Running on Android 4.1 Jb)
How to Get File in Assets from Android Ndk
Adding Button Action in Custom Notification
How to Get String from Different Locales in Android
Get the Id of a Drawable in Imageview
How to Get Current Activity's Layout and Views via Adb
Is This the Right Way to Clean-Up Fragment Back Stack When Leaving a Deeply Nested Stack
How to Read Value from String.Xml in Android
Referencing a String in a String Array Resource with Xml
How to Set Up Android Emulator Proxy Settings
Pop Up Window Over Android Native Incoming Call Screen Like True Caller Android App
Android Gradle Could Not Reserve Enough Space for Object Heap
Open an Image Using Uri in Android's Default Gallery Image Viewer