[英]How we can use images from APK main expansion file?
我從最近兩天開始面臨一個問題,即我們如何在Google Play上上傳大小超過50Mb的.apk文件,然后我找到了一種方法,可以通過鏈接http://developer.android.com通過APK擴展文件上傳.apk /guide/market/expansion-files.html現在可以成功了,但是現在遇到了問題,我該如何從對象中的主擴展文件讀取文件,就像.obb格式一樣
但是現在可以使用來自主要擴展文件的.mp3文件,例如:
AssetFileDescripto assetFileDescriptor = zipResourceFile.getAssetFileDescriptor(
"assets/all_types_of_people1.mp3");
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource( assetFileDescriptor.getFileDescriptor(),
assetFileDescriptor.getStartOffset(),assetFileDescriptor.getLength());
但是,如何使用從主擴展文件到WebView的圖像?
由於可以從zipResourceFile獲取流,因此可以使用BitmapFactory從中創建圖像。
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線程外執行此操作。
dagalpin已經給出了一種如何獲取InputStream的方法。
閱讀您的HTML文件並將其轉換為UTF-8字符串。
並加載如下。
// 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.
我還沒有測試。 但它似乎正在工作。
而不是僅使用圖像名稱,請使用expansionfiles / myFilePath.jpg
InputStream是= zipResourceFile.getInputStream(“ expansionfile / myFilePath.jpg”);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.