Be happy

안드로이드 스튜디오에서 웹서버에서 보낸 이미지 받기 본문

Fish in my hands (2018.3~2018.6)/안드로이드 스튜디오

안드로이드 스튜디오에서 웹서버에서 보낸 이미지 받기

해퓌해퓌 2018. 6. 22. 23:55

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

Comments