参见英文答案 Android load from URL to Bitmap17个 我有一个uri喜欢哪个有图像 file:///mnt/............... 如何使用这个uri来获取图像,但它返回null,请告诉我我错在哪里. Bitmap bitmap = BitmapFactory.decode
我有一个uri喜欢哪个有图像
file:///mnt/...............
如何使用这个uri来获取图像,但它返回null,请告诉我我错在哪里.
Bitmap bitmap = BitmapFactory.decodeFile(uri.getPath()); Bitmap bitmap = BitmapFactory.decodeFile(uri.toString());这是一种简单的单行方式:
try { URL url = new URL("http://...."); Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream()); } catch(IOException e) { System.out.println(e); }