Khi tôi gọi hàm này, không có hình ảnh nào trong chế độ xem hình ảnh bitmapFactory.decodefile(filename)
hiển thị null .. vui lòng trợ giúp cho việc này.Bitmap trả về null từ BitmapFactory.decodeFile (tên tệp)
Đây là mã của tôi:
public Bitmap ShowImage(String imageName,String userImageName)
{
File sdcard_mainDirectory = new File(Environment.getExternalStorageDirectory(),"UserImages").getAbsoluteFile();
File file = new File(sdcard_mainDirectory, userImageName).getAbsoluteFile();
if (file != null) {
try {
String imageInSD = "/sdcard/UserImages/"+userImageName;
Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
return bitmap;
}
catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
Đăng stackTrace. – st0le