안드로이드 스튜디오에서 웹서버에서 보낸 이미지 받기
private void getImage() {
String id = editTextId.getText().toString().trim();
class GetImage1 extends AsyncTask<String, Void, Bitmap> {
ProgressDialog loading;
@Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(Book.this, "Uploading...", null, true, true);
}
@Override
protected void onPostExecute(Bitmap b) {
super.onPostExecute(b);
loading.dismiss();
imageView3.setImageBitmap(b);
}
@Override
protected Bitmap doInBackground(String... params) {
String id = params[0];
String add1 = "url 주소";
URL url1 = null;
Bitmap image1 = null;
try {
url1 = new URL(add1);
image1 = BitmapFactory.decodeStream(url1.openConnection().getInputStream());
//image1.setWidth();
PublicValues.Book_bitmap3 = image1;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return image1;
}
}
GetImage1 gi1 = new GetImage1();
gi1.execute(id);
}
php : http://prettymen.tistory.com/38?category=753669