【发布时间】:2016-06-20 12:14:45
【问题描述】:
如何在 Android 中从InputStream(base64 String) 获取位图图像?
下面是我的代码:
protected Bitmap doInBackground(Void... params) {
Bitmap image;
URL url1 = null;
try {
url1 = new URL("http://sunnyfacemash.atwebpages.com/get.php"); // url
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
image = BitmapFactory.decodeStream(url1.openConnection().getInputStream());
return image;
} catch (IOException e) {
image = null;
e.printStackTrace();
}
return image;
}
【问题讨论】:
-
刚刚在浏览器中打开了你的 php url 它正在显示一些字符串是 base64 字符串吗?
-
是的,它是一个 base64 字符串。我想得到那个字符串并在android中显示图片。
-
this 答案包含转换字符串到基数,反之亦然
标签: java android bitmap inputstream