3

我想从 sd 卡/文件夹中获取带有标签名称和图标的已卸载 apk 文件信息,以显示在列表视图中。

为此我正在尝试

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

           PackageManager pm = this.getPackageManager();

           String dir = "mnt/sdcard/" + FilesInFolder.get(i);
           PackageInfo pi=pm.getPackageArchiveInfo(dir,0);
           System.err.println("files were " + pi);
           pi.applicationInfo.sourceDir = dir;
           pi.applicationInfo.publicSourceDir = dir;
           Drawable APKicon = pi.applicationInfo.loadIcon(pm);
           String AppName = (String)pi.applicationInfo.loadLabel(pm);

       }

FilesInFolder 是一个ArrayList<String>将所有文件名存储在 sd 卡文件夹中的位置。我能够从 sd 卡文件夹中正确获取所有文件,但我将PackageInfo pi所有文件的值设为 null

这是我的日志猫

  10-29 00:55:14.832: W/PackageParser(17057): Skipping dir: mnt/sdcard/tudou.apk
  10-29 00:55:14.832: W/System.err(17057): files were null
  10-29 00:55:14.833: W/PackageParser(17057): Skipping dir:       mnt/sdcard/com.nexbits.video-1.apk
  10-29 00:55:14.833: W/System.err(17057): files were null
  10-29 00:55:14.834: W/PackageParser(17057): Skipping dir: mnt/sdcard/com.myapp.locksettings-2.apk
  10-29 00:55:14.834: W/System.err(17057): files were null

任何人都可以让我在我坚持的地方吗?

4

0 回答 0