How Android Gets the system application size

Source: Internet
Author: User

list<packageinfo> packages = Getpackagemanager (). getinstalledpackages (0);
Public Pkgsizeobserver pkgsizeobserver = new Pkgsizeobserver ();
try {Method Method;method = This.getpackagemanager (). GetClass (). GetMethod ("Getpackagesizeinfo", new class[] { String.class,ipackagestatsobserver.class}); Method.invoke (This.getpackagemanager (), PackageInfo.packageName, Pkgsizeobserver);} catch (Nosuchmethodexception e) {//TODO auto-generated catch Blocke.printstacktrace ();} catch (Illegalaccessexception E {//TODO auto-generated catch Blocke.printstacktrace ();} catch (IllegalArgumentException e) {//TODO auto-generated catch Blocke.printstacktrace ();} catch ( InvocationTargetException e) {//TODO auto-generated catch Blocke.printstacktrace ();} Synchronized (pkgsizeobserver) {try {pkgsizeobserver.wait ();} catch (Interruptedexception e) {e.printstacktrace ()}} Totalapp = pkgsizeobserver.cachesize + pkgsizeobserver.codesize+ pkgsizeobserver.datasize;
<span style= "font-family:arial, Helvetica, Sans-serif;" >PkgSizeObserver.class</span>
Aidl file Bindler mechanism service class public class Pkgsizeobserver extends Ipackagestatsobserver.stub {public long cachesize = 0; public long datasize = 0;public long codesize = 0;/*** * callback function, *  * @param pStatus *            , return data encapsulated in Packagestats object * @par AM succeeded *            for callback success */@Overridepublic void ongetstatscompleted (Packagestats pstats, Boolean succeeded) throws remoteexception {//TODO auto-generated Method Stubif (succeeded) {cachesize = pstats.cachesize;//cache Size DataSize = PSTATS.D Atasize; Data size codesize = pstats.codesize; Application size synchronized (this) {This.notifyall ();}}}}


How Android Gets the system application size

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.