0

我正在尝试从 sdcard 获取图像以将其显示在 android 的 imageview 中。它显示错误为 SkImageDecoder:factory 在 android emulator2.2 中返回 null。这是我在 android 中从 SDcard 检索图像到 imageview 的代码。

File imgFile = new File("/sdcard/wm.png");
if (imgFile.exists()) {
     Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
     ImageView myImage = (ImageView) findViewById(R.id.imageView1);
     myImage.setImageBitmap(myBitmap);
}

请解决此问题。

4

1 回答 1

0

使用Environment.getExternalStorageDirectory()Environment.getExternalStoragePublicDirectory而不是硬编码 sd 卡的路径(即"/sdcard/wm.png")。

于 2012-12-04T09:22:32.153 回答