Android的扩展文件 [英] Android expansion file

查看:309
本文介绍了Android的扩展文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做包含〜PNG的80mo的应用程序(这是一个离线应用程序,所以我必须把它们存储在手机上)。

I am trying to do an application which contain ~80mo of PNG (It's an offline app so I have to store them on the phone).

应用程序完全在地方,但我不能上传APK> 50mo。所以我想实现其中将包含所有的PNG文件的扩展文件。所以,我用在Linux上这个简单的命令: _zip_ -0 _main.1.com.ctai.irisst.zip_ * _巴_ 在我的/ RES /绘制-MDPI创建我的扩展文件,然后将其手动 /Android/data/com.ctai.irisst /
然后,我用<一个href="http://stackoverflow.com/questions/7697466/unzip-a-zipped-file-on-sd-card-in-android-application">this code 以解压缩在手机的存储所有的数据,但是当我启动应用程序,我只得到了一个空白的屏幕像10秒,然后安卓告诉我,该应用程序不响应。我可以在〜10 PNG图像解压缩的文件浏览器,并在看到的logcat 的1文件提取每一秒。 (如果我使用缓冲区,它仍然采取> 20岁载入我的应用程序)

The application works perfectly in local but I can't upload an apk > 50mo. So I am trying to implement an expansion file which will contain all my PNGs. So I use this simple command on Linux: _zip_ -0 _main.1.com.ctai.irisst.zip_ *_.png_ on my /res/drawable-mdpi to create my expansion file and then put it manually to /Android/data/com.ctai.irisst/
Then, I use this code to unzip all my data on the storage of the phone, but when I start the app, I only get a blank screen for like 10s, and then Android tells me that the application is not responsive. I can see in a file explorer that ~10 PNG images are unzipped and in the Logcat that 1 file is extracted every second. (and if I use a buffer, it still take >20s to load my application)

我已经实现了以下库:

"downloader_library","licencing_library","Sample_downloader" and "zip_file"  

但我并没有真正使用它的那一刻。 (要这样呢?怎么样?)

but I didn't really used it for the moment. (should I ? How ?)

我的问题很简单,我怎么能简单地创建一个扩展文件,并用我的影像,而无需与用户体验的干扰?我还没有找到扩展的文件,并没有样本项目这么多的教程,所以我有点失去了。

My question is simple, how can I simply create an expansion file and use my images without interfering with the user experience ? I have not found so many tutorials on Expansion Files, and no sample projects, so I'm a bit lost.

推荐答案

您不需要解压你的包。你可以阅读在扩展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);

**编辑**

请注意,在code以上,的InputStream 将指向文件您的ZIP压缩包里面,而不是ZIP文件本身。例如,如果放置的 flower.png 的一个名为目录下的背景的你的ZIP压缩包里面,你可以有一个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,你需要创建   目录安卓/ 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.

在成功的测试,您可以与您的APK通过开发者控制台上传您的扩展ZIP。

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

你有没有通读 APK扩展文件?这是pretty的简单。

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

这篇关于Android的扩展文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆