dalmif
شنبه 02 خرداد 1394, 15:48 عصر
سلام دوستان.
یه کدی به شکل زیر نوشتم:
public static Bitmap getimageURL (final String urli) {
Thread m = new Thread() {
@Override
public void run() {
super.run();
try {
URL url = new URL(urli);
//try this url = "http://0.tqn.com/d/webclipart/1/0/5/l/4/floral-icon-5.jpg"
HttpGet httpRequest = null;
httpRequest = new HttpGet(url.toURI());
Log.i("imageSwitcherURL", "s: " + url);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
InputStream input = b_entity.getContent();
bitmap = BitmapFactory.decodeStream(input);
Log.i("imageSwitcherbitmap", "s: " + bitmap);
} catch (Exception ex) {
} finally {
}
}
};
m.start();
return bitmap;
}
دفعه اول که میام توی صفحه خالی return میشه اما وقتی عقب میزنم و برای بار دوم میام توی اکتیویتی درست میاره
مشکل چیه؟؟
اینم بگم که Birmap bitmap; هم در بالا همه کد ها نوشتم.
یه کدی به شکل زیر نوشتم:
public static Bitmap getimageURL (final String urli) {
Thread m = new Thread() {
@Override
public void run() {
super.run();
try {
URL url = new URL(urli);
//try this url = "http://0.tqn.com/d/webclipart/1/0/5/l/4/floral-icon-5.jpg"
HttpGet httpRequest = null;
httpRequest = new HttpGet(url.toURI());
Log.i("imageSwitcherURL", "s: " + url);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
InputStream input = b_entity.getContent();
bitmap = BitmapFactory.decodeStream(input);
Log.i("imageSwitcherbitmap", "s: " + bitmap);
} catch (Exception ex) {
} finally {
}
}
};
m.start();
return bitmap;
}
دفعه اول که میام توی صفحه خالی return میشه اما وقتی عقب میزنم و برای بار دوم میام توی اکتیویتی درست میاره
مشکل چیه؟؟
اینم بگم که Birmap bitmap; هم در بالا همه کد ها نوشتم.