I'm trying to put a image inside an ImageView, but I can't do it. When the method finishes, it doesn't show anything in the ImageView, because loadimage
returns null. Why is this?
This is the code:
private void setSign() {
File[] files = ImagesUtilities.getImages(directory, id);
for (int i = 0; i < files.length; i++) {
if (!files[i].getName().contains("firma")) {
signFile = files[i].getAbsolutePath();
}
}
if(new File(signFile).exists()){
sign.setImageBitmap(loadImage(signFile));
sign.invalidate();
}
}
private Bitmap loadImage(String imgPath) {
BitmapFactory.Options options;
try {
options = new BitmapFactory.Options();
options.inSampleSize = 2;
Bitmap bitmap = BitmapFactory.decodeFile(imgPath, options);
return bitmap;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
The value of signFile in the last try its: /storage/emulated/0/Pictures/181/20140414153624/firma357840194.jpg