Android 从json加载图像时出现问题/为什么我的位图为空?

Android 从json加载图像时出现问题/为什么我的位图为空?,android,json,bitmap,android-asynctask,bitmapimage,Android,Json,Bitmap,Android Asynctask,Bitmapimage,我一直在试图理解为什么我的位图是空的,但到目前为止我还不能做到。这就是我的模型中的内容: public Bitmap getBitmapFromUrl(String imageURL) { Bitmap bitmap = null; HttpGet httpRequest = null; HttpClient httpclient = new DefaultHttpClient(); try { URL urlImage = new URL(

我一直在试图理解为什么我的位图是空的,但到目前为止我还不能做到。这就是我的模型中的内容:

 public Bitmap getBitmapFromUrl(String imageURL) {

    Bitmap bitmap = null;
    HttpGet httpRequest = null;
    HttpClient httpclient = new DefaultHttpClient();

    try {
        URL urlImage = new URL(imageURL);
        httpRequest = new HttpGet(urlImage.toURI());
        HttpResponse httpResponse = (HttpResponse) httpclient.execute(httpRequest);

        HttpEntity entity = httpResponse.getEntity();
        BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
        InputStream input = b_entity.getContent();

        bitmap = BitmapFactory.decodeStream(input);

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    System.out.println(bitmap);
    return bitmap;
}
这就是我的
异步任务的
onPostExecute
中的内容:

protected void onPostExecute(JSONArray json) {

            dialog.dismiss();

            Intent intent = getIntent();
            Bundle extras = intent.getExtras();
            position = extras.getString("position");
            int positionInt = Integer.parseInt(position);

            String price = "";
            String description = "";
            String image = "";

            try {
                JSONObject ad = json.getJSONObject(positionInt);
                price = ad.getString("price");
                description = ad.getString("description");
                image = ad.getString("image");
            } catch (JSONException ex) {
                ex.printStackTrace();
            }

            TextView viewPrice = (TextView) findViewById(R.id.ad_view_price);
            viewPrice.setText(price);

            TextView viewDescription = (TextView) findViewById(R.id.ad_view_description);
            viewDescription.setText(description);

            final String imageURL = "http://192.168.0.16:3000" + image;

            Bitmap bitmap = jParser.getBitmapFromUrl(imageURL);
            System.out.println(bitmap);
            img = (ImageView) findViewById(R.id.ad_view_photo_image);
            img.setImageBitmap(bitmap);

            super.onPostExecute(json);

        }

提前感谢您的帮助

你看到日志了吗?您是否尝试过从浏览器中使用相同的URL?是的,相同的URL在浏览器中也可以正常工作。我不明白。我试图让图像请求进入我的模型,就像我上面展示的那样,但是我放弃了,把它放在我的活动中。这不是我想要的,但它奏效了。