我们如何使用来自 APK 主扩展文件的图像? [英] How we can use images from APK main expansion file?

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

问题描述

我在过去 2 天面临一个问题,即我们如何在 Google Play 上上传大小超过 50Mb 的 .apk 文件,然后我找到了一种方法来上传带有 APK 扩展文件的 .apk 链接 http://developer.android.com/guide/market/expansion-files.html现在我终于成功了,但现在我遇到了问题,如何从我的对象中的主扩展文件中读取文件,就像它是 .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?

推荐答案

由于可以从 zipResourceFile 获取流,因此可以使用 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天全站免登陆