I’m trying to get a pic just made it with the cam with the next code, but I have always the same error:
skia(446): --- SkImageDecoder::Factory returned null
(It doesn’t throw an exception). So the object bitmap is always NULL and I can’t see the pic just made it with the cam, and which I can see it with the File Explorer from Eclipse.
What happened? How can I fix this?
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.view_photo);
ImageView imagen = (ImageView)findViewById(R.id.foto);
try {
Cursor cur = this.getContentResolver().query(Media.EXTERNAL_CONTENT_URI, null, null, null,null);
String str = cur.getString(cur.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
cur.moveToLast();
FileInputStream in = new FileInputStream("/sdcard/DCIM/Camera/" + str);
BufferedInputStream buf = new BufferedInputStream(in, 24);
Bitmap bMap = BitmapFactory.decodeStream(buf);
if (bMap != null)
imagen.setImageBitmap(bMap);
else{
Log.d("onCreate: ", "bMap es NULL");
}
if (in != null) {
in.close();
Log.d("onCreate: ", "in cerrado");
}
if (buf != null) {
buf.close();
Log.d("onCreate: ", "buf cerrado");
}
Log.d("onCreate: ", "Fin del proceso");
}catch (Exception e) {
Log.e("Error reading file", e.toString());
}
}
Try the following things: