久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

IPackageStatsObserver 無法解析為類型(Android)

IPackageStatsObserver cannot be resolved to a type (Android)(IPackageStatsObserver 無法解析為類型(Android))
本文介紹了IPackageStatsObserver 無法解析為類型(Android)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想計算使用設備的所有緩存內存的總和.為此,我收到編譯時間錯誤:

I want to calculate the sum of all the cache memory utilizing the device. For this I am getting a compiled time error:

IPackageStatsObserver cannot be resolved to a type

我在代碼中已經兩次提到這個錯誤:

I have mentioned this error 2 times in the code:

public long totalCacheSize(){
    totalSize=0;

    PackageManager packageManager = getApplicationContext().getPackageManager();

     /* List<PackageInfo> packs = packageManager
      .getInstalledPackages(PackageManager.GET_ACTIVITIES);*/
     // PackageManager.GET_META_DATA

    List<PackageInfo> packs = packageManager
            .getInstalledPackages(PackageManager.GET_META_DATA);

    for (int i = 0; i < packs.size(); i++) {

        PackageInfo p = packs.get(i);

        Method getPackageSizeInfo;
        try {
            getPackageSizeInfo = packageManager.getClass()
                    .getMethod("getPackageSizeInfo",
                        String.class, Class.forName("android.content.pm.IPackageStatsObserver"));

            getPackageSizeInfo.invoke(packageManager, p.packageName,
                    new IPackageStatsObserver.Stub() { //error

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

                            totalSize = totalSize + pStats.cacheSize;
                            Log.d("size", totalSize+"");
                            Toast.makeText(getApplicationContext(), "size"+totalSize, Toast.LENGTH_SHORT).show();
                        }
                    }
            );

        } catch (Exception e) {
            try {
                getPackageSizeInfo = packageManager.getClass()
                        .getMethod("getPackageSizeInfo",
                            String.class, Class.forName("android.content.pm.IPackageStatsObserver"));

                getPackageSizeInfo.invoke(packageManager, p.packageName,
                        new IPackageStatsObserver.Stub() { //error

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

                                totalSize = totalSize + pStats.cacheSize;
                                Log.d("size", totalSize+"");
                                Toast.makeText(getApplicationContext(), "size"+totalSize, Toast.LENGTH_SHORT).show();
                            }
                        }
                );
            } catch (Exception ee) {
                Log.d("eeeeeeeeeee", "error");
                ee.printStackTrace();
            } 
        } 
    }

    Log.d("return size", totalSize+"");
    Toast.makeText(getApplicationContext(), "return size"+totalSize, Toast.LENGTH_SHORT).show();
    return totalSize;
}

IPackageStatsObserver 在 android SDK 中不可用.可能使用 Class.forName() 加載 Stub 類,找到默認構造函數并調用它以獲取 Stub 的新實例.但是我應該編碼它,我對此一無所知!?

IPackageStatsObserver is not available in android SDK. Perhaps loading the Stub class using Class.forName(), finding the default constructor and invoke it to get a new instance of a Stub. But what should I code it, I do not know anything about it!?

求救!!

推薦答案

要解決您的問題,請按以下步驟操作:

To resolve your issue follow these steps:

Android Studio

  • 右鍵單擊您的項目新建 > 文件夾 > AIDL 文件夾
  • 完成
  • 右擊aidl文件夾新建>包
  • 插入 android.content.pm 并按 OK
  • 下載IPackageStatsObserver.aidl
  • 復制android.content.pm包內的aidl文件
  • 構建 > 重建項目
  • Right click on your project New > Folder > AIDL Folder
  • Press Finish
  • Right click on aidl folder New > Package
  • Insert android.content.pm and press OK
  • Download IPackageStatsObserver.aidl
  • Copy the aidl file inside the android.content.pm package
  • Build > Rebuild Project

Eclipse

  • 右鍵src文件夾新建>包
  • 插入 android.content.pm
  • 完成
  • 下載IPackageStatsObserver.aidl
  • 復制android.content.pm包內的aidl文件
  • 選擇 totalCacheSize 的類,然后 Source > Organize Imports
  • Right click on src folder New > Package
  • Insert android.content.pm
  • Press Finish
  • Download IPackageStatsObserver.aidl
  • Copy the aidl file inside the android.content.pm package
  • Select class where totalCacheSize is then Source > Organize Imports

這篇關于IPackageStatsObserver 無法解析為類型(Android)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why would you choose Android API over Google APIs in the SDK on Eclipse?(為什么在 Eclipse 的 SDK 中選擇 Android API 而不是 Google API?)
Couchbase Bucket authentication error(Couchbase 存儲桶身份驗證錯誤)
admob 6.2.1 nullpointer exception(admob 6.2.1 空指針異常)
How to setup SDK in IntelliJ IDEA?(如何在 IntelliJ IDEA 中設置 SDK?)
My phone cannot be detected in eclipse to test run(eclipse 無法檢測到我的手機進行試運行)
platform-toolsaapt.exe directory missing in android SDK(android SDK 中缺少 platform-toolsaapt.exe 目錄)
主站蜘蛛池模板: 91青青草 | 久久色av | 亚洲精品乱码久久久久久蜜桃91 | 亚洲天堂2014 | 国产一区高清 | 免费网站观看www在线观看 | 国产a一级 | 亚洲久久在线 | 亚洲欧美日韩在线 | 天天操天天操天天操 | 国产伦精品一区二区 | 激情福利视频 | 久久精品一区二区国产 | 欧美精品一区二区在线观看 | 一级片日韩 | 欧美精品在线看 | 欧美一级淫片免费视频魅影视频 | 美国一级大黄一片免费中文 | 狠狠做深爱婷婷久久综合一区 | 我要看一级黄色片 | www.久久爱 | 久久久久网 | 中文字幕一区二 | 日日夜夜艹| 五月婷婷中文字幕 | 另类ts人妖一区二区三区 | 精品在线免费视频 | 一区二区三区日韩 | 黄色网址av| 精品国产乱码久久久久久蜜柚 | 欧美a在线| 日日操日日操 | 国产又粗又猛又黄又爽的视频 | 在线观看免费黄色 | 中文字幕在线视频播放 | 久久男人的天堂 | 一级特黄aaaaaa大片 | 欧美日韩免费 | 国产三级黄色片 | 亚洲精品一区二区三区在线观看 | 91精品国产日韩91久久久久久 |