[英]How do I change my code to use APK Expansion file?
My application is over 50MB because I use a lot of MP3 files. 我的应用程序超过50MB,因为我使用了很多MP3文件。 I typical do this ... 我通常这样做...
uri = Uri.parse("android.resource://red.cricket.RecordAlbum/" + R.raw.track_001_64kb );
... but if I have to use APK Expansion file I assume the above line of code has to change. ...但是如果我必须使用APK扩展文件,我认为上面的代码行必须更改。 But change to what? 但是变成什么呢? Any help is greatly appreciated! 任何帮助是极大的赞赏!
Edit 1) Thanks for your answer Ted. 编辑1)感谢您的回答泰德。 I did create the expansion file like so: 我确实是这样创建扩展文件的:
red@ubuntu:~/android/workspace/Album/res/raw$ zip -n .mp3 main.1.com.redcricket.Album.obb *mp3
So what do I do now? 那我现在该怎么办? rm -f *mp3; cd ../..; ant clean ; ant debug
rm -f *mp3; cd ../..; ant clean ; ant debug
Somehow I do not think that is going to work. rm -f *mp3; cd ../..; ant clean ; ant debug
不知何故我认为这行不通。 Where do I put the main.1.com.redcricket.Album.obb
file? 我应该将main.1.com.redcricket.Album.obb
文件放在哪里?
The steps are pretty clearly laid out in the docs . 这些步骤在文档中已明确列出。 In outline, the steps are: 概括而言,这些步骤是:
Rewrite the app to look for the expansion file in the location 重写应用以在该位置查找扩展文件
Context ctx = getContext(); String loc = ctx.getExternalStorageDirectory() + "/Android/obb/" + ctx.getPackageName();
Write code so that if the file is not there, your app will download it from Google Play, using the Application Licensing service as described in the docs. 编写代码,以便如果文件不存在,您的应用程序将使用文档中所述的应用程序许可服务从Google Play下载文件。 There's quite a bit of coding and configuration involved in this step. 此步骤涉及很多编码和配置。
Also see this thread for more details on how to do all this. 另请参阅此线程以获取有关如何执行所有操作的更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.