SkImageDe codeR:工厂返回null [英] SkImageDecoder:factory returned null

查看:152
本文介绍了SkImageDe codeR:工厂返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从SD卡获取图像中的机器人来的ImageView显示它。它的示值误差为SkImageDe codeR:工厂机器人emulator2.2空返回。这里是我的code从SD卡中的Andr​​oid检索图像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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆