我们如何能够从主APK扩展文件使用的图片? [英] How we can use images from APK main expansion file?

查看:129
本文介绍了我们如何能够从主APK扩展文件使用的图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

米最后2天面临的一个问题,我们如何可以上传在谷歌一个.apk文件播放其大小超过50MB然后我找到一种方法,从链接的 http://developer.android.com/guide/market/expansion-files.html
现在m,在最终会取得成功,但现在中号有问题,我怎么能在我的阅读对象从主扩展文件的文件就像是.obb格式

m facing a problem from last 2 days that how we can upload a .apk file on Google play having size more than 50Mb then i find a way to upload a .apk with APK Expansion File from link http://developer.android.com/guide/market/expansion-files.html now m succeed at end but now m having problem how can i read file from that main Expansion file in my object like it is in .obb format

但是,现在能够从主扩展文件使用.mp3文件,如:

But now able to use .mp3 files from main expansion file like:

AssetFileDescripto assetFileDescriptor = zipResourceFile.getAssetFileDescriptor( 
  "assets/all_types_of_people1.mp3");
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource( assetFileDescriptor.getFileDescriptor(), 
  assetFileDescriptor.getStartOffset(),assetFileDescriptor.getLength());

但是,我们如何使用从主扩展文件图像的WebView?

But how can we use images from main expansion file to WebView?

推荐答案

由于人们可以从一个子presourceFile流,可以使用BitmapFactory从他们创造的图像。

Since one can get a stream from a zipResourceFile, one can use BitmapFactory to create images from them.

InputStream is = zipResourceFile.getInputStream("myFilePath.jpg");
BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap b = BitmapFactory.decodeStream(is, null, bfo);

请注意,由于解码还需要一段时间,你会想这样做出来的UI线程的。

Note that since decoding will take some time, you'll want to do this out of the UI thread.

这篇关于我们如何能够从主APK扩展文件使用的图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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