且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

安卓扩展文件

更新时间:2023-08-19 16:35:16

您无需解压缩包.您可以使用以下命令读取扩展 ZIP 文件中的所有 PNG:

You don't need to unzip your package. You can read all your PNGs within Expansion ZIP file with this:

// Get a ZipResourceFile representing a merger of both the main and patch files
ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(appContext,
        mainVersion, patchVersion);

// Get an input stream for a known file inside the expansion file ZIPs
InputStream fileStream = expansionFile.getInputStream(pathToFileInsideZip);

**编辑**

请注意,在上面的代码中,InputStream 将指向 ZIP 存档中的文件,而不是 ZIP 文件本身.例如,如果您将 flower.png 放在 ZIP 存档中名为 background 的目录下,则可以按如下方式为该文件设置 InputStream:

Notice that in the code above, InputStream will point to the file inside your ZIP archive and not the ZIP file itself. For example, if you placed flower.png under a directory called background inside your ZIP archive, you can have an InputStream to that file as follows:

InputStream fileStream = expansionFile.getInputStream("background/flower.png");

**编辑**

我认为您放置 ZIP 文件的位置不正确.根据开发者指南:

I think the location in which you placed your ZIP file is incorrect. According to Developer's Guide:

如果你的包名是com.example.android,你需要创建共享存储上的目录 Android/obb/com.example.android/空间.

If your package name is com.example.android, you need to create the directory Android/obb/com.example.android/ on the shared storage space.

测试成功后,您可以通过开发者控制台上传扩展包 ZIP 和 APK.

After successful testing, you can upload your Expansion ZIP along with your APK through Developer's Console.

您是否已阅读APK 扩展文件?非常简单.

Have you read through the APK Expansion Files? It's pretty straightforward.