アドレスはmUrlで取れているものBitmapに変換できないという状況です
getimageからsetimageまでに問題があります。
ご指摘をください
コード public class ImageLoaderTask extends AsyncTask<ImageView,Void,Bitmap> { private static final String USER_AGENT = "WeatherForecasts sample"; private final Context context; private String mUrl; private Bitmap bmap; Exception exception; ImageView imageview; public ImageLoaderTask(Context context,String url) { this.context = context; mUrl = url; Log.d("","@@ mUrl1 = " + mUrl); } @Override protected Bitmap doInBackground(ImageView... params) { imageview = params[0]; // String url = (String) imageview.getTag(); Log.d("","@@ mUrl2 = " + mUrl); try { Bitmap map= getImage(context,mUrl); Log.d("bmap-iamge","map="+map); // getImage(context, mUrl); } catch (IOException e) { exception = e; } return null; } // @Override protected void onPostExecute(Bitmap bitmap) { bmap=bitmap; super.onPostExecute(bmap); Log.d("bitmap o","@@ bitmap o = " + bmap); if (bitmap != null) { imageview.setImageBitmap(bmap); } } private static Bitmap getImage(Context context, String url) throws IOException { URL url1 = new URL(url); HttpURLConnection con = null; try { con = (HttpURLConnection) url1.openConnection(); con.setRequestMethod("GET"); con.connect(); int status = con.getResponseCode(); if (status == HttpURLConnection.HTTP_OK) { return BitmapFactory.decodeStream(con.getInputStream()); // Log.d("pic","pic="+pic); // Bitmap bmap2=BitmapFactory.decodeStream(con.getInputStream()); // Log.d("bmap2","bmap="+bmap2); } else { return null; } } catch (Exception e) { Log.d("", "exception1 = " + e.toString()); } finally { if (con != null) { con.disconnect(); } return null; } } }
問題があるならそれを質問に書いてください。
回答1件
あなたの回答
tips
プレビュー