相关疑难解决方法(0)

启动Intent.ACTION_VIEW意图无法处理已保存的图像文件

首先让我说这个问题与我的另一个问题有点联系.实际上它是因为这个而创建的.

我有以下代码将从网上下载的位图写入SD卡中的文件:

// Get image from url
URL u = new URL(url);
HttpGet httpRequest = new HttpGet(u.toURI());
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();
Bitmap bmImg = BitmapFactory.decodeStream(instream);
instream.close();

// Write image to a file in sd card
File posterFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Android/data/com.myapp/files/image.jpg");
posterFile.createNewFile();
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(posterFile));
Bitmap mutable = Bitmap.createScaledBitmap(bmImg,bmImg.getWidth(),bmImg.getHeight(),true);
mutable.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();

// Launch default …
Run Code Online (Sandbox Code Playgroud)

java android bitmap android-intent

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

android-intent ×1

bitmap ×1

java ×1