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
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());
But how can we use images from main expansion file to WebView?
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);
Note that since decoding will take some time, you'll want to do this out of the UI thread.
dagalpin already given a way how to get as InputStream.
Read your HTML file and convert it to UTF-8 String.
and load as below.
// you can also load from an HTML string:
String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", null);
// ... although note that there are restrictions on what this HTML can do.
// See the JavaDocs for loadData() and loadDataWithBaseURL() for more info.
I have not tested it. But it seems to be working.
Instead of only image name use expansionfiles/myFilePath.jpg
InputStream is = zipResourceFile.getInputStream("expansionfile/myFilePath.jpg");
来源:https://stackoverflow.com/questions/10738818/how-we-can-use-images-from-apk-main-expansion-file