SkImageDe codeR:工厂返回null [英] SkImageDecoder:factory returned null
问题描述
我想从SD卡获取图像中的机器人来的ImageView显示它。它的示值误差为SkImageDe codeR:工厂机器人emulator2.2空返回。这里是我的code从SD卡中的Android检索图像ImageView的。
I am trying to get the image from sdcard to display it in an imageview in android. Its showing error as SkImageDecoder:factory returned null in android emulator2.2. Here is my code to retrieve image from SDcard to imageview in android.
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);
}
请解决这个问题。
推荐答案
使用<一个href=\"http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory%28%29\"相对=nofollow> Environment.getExternalStorageDirectory()或<一个href=\"http://developer.android.com/reference/android/os/Environment.html#getExternalStoragePublicDirectory%28java.lang.String%29\"相对=nofollow> Environment.getExternalStoragePublicDirectory的不是硬编码的SD卡(即/ SD卡/ wm.png
)的路径。
Use Environment.getExternalStorageDirectory() or Environment.getExternalStoragePublicDirectory instead of hard coding the path of the sd card (i.e "/sdcard/wm.png"
).
这篇关于SkImageDe codeR:工厂返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!