0

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?

Nikhil Lamba
  • 593
  • 1
  • 6
  • 17

3 Answers3

1

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
  • 1,297
  • 8
  • 8
  • 1
    any clue for accessing html files from OOB file like how we access the html from webview Ex: WebView wv = (WebView)this.findViewById(R.id.splashWebView); wv.loadUrl("file:///android_asset/html_no_copy/test.html"); or how to unzip or extract all data from OBB file? – LOG_TAG Aug 01 '12 at 04:28
0

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.

Ajay Kumar Meher
  • 1,932
  • 16
  • 24
0

Instead of only image name use expansionfiles/myFilePath.jpg

InputStream is = zipResourceFile.getInputStream("expansionfile/myFilePath.jpg");

Mahesh
  • 2,862
  • 2
  • 31
  • 41