android - Getting installed app size -


I would like to achieve an installed app size, I am trying to learn it.
what has already failed:
- new file ( "/ data / app / some.apk ') - Report incorrect size
- PackageManager.getPackageSizeInfo (string PackageName, IPackageStatsObserver Observer) - the @hide and depends on some obscure IPackageStatsObserver results so I can not call it through reflection .

Unfortunately, the current official to do so. However, if you import AIDL and generate stubs in our project, then you can call the hidden method. You can use the reflection to reapply:

  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 successful) throws RemoteException {Log.i (TAG, "codeSize:" + pStats.codeSize );}});   

This is the reason that for obviously a big hack and for public applications.



  • Comments

    Popular posts from this blog

    excel vba - How to delete Solver(SOLVER.XLAM) code -

    github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

    ios - Replace text in UITextView run slowly -