Android - AQuery在回调方法上获取图像

时间:2014-03-04 01:25:16

标签: android httprequest google-places-api androidhttpclient aquery

您好我有一个请求网址(Google商家信息请求网址),我得到的回复是图片。如何在回调函数上获取图像?

更新

AQuery aQuery = new AQuery(getApplicationContext());
String urlString = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CnRoAAAAGJs3jtWR_Dm_lQSan6ha40TR2IKPlqbLQ5-slSCxPJJIksM2GmiEhqBtmhtdu9_njLxvFMyTMz-e_FoDIZuKmoS65Uc1AeD4kWjrJ4SwEjgT4ac-KtfNaX4Lg0FOqJRCN33ylJikCF29bgqKCcNUQxIQ0OvXpGXfUT3ADICQqP_QOhoUBlByoB4FKPp1woIKVb2Z01bblrw&sensor=true&key=AIzaSyB-tx7MBOQk4qya_vnmwHlQDao-SufKuBw";

aQuery.ajax(urlString, String.class, new AjaxCallback<String>(){
    @Override
    public void callback(String url, String content, AjaxStatus 

           //Here "content" is the response that I'm getting. Currently I'm getting this as a String I don't know how to get it as a image 

    }
});

1 个答案:

答案 0 :(得分:2)

像这样:

final AjaxCallback<Bitmap> cb = new AjaxCallback<Bitmap>() {
    @Override
    public void callback(String url, Bitmap bm, AjaxStatus status) {
         // do whatever you want with bm (the image)
        }
    };
final AQuery aq = new AQuery(ctx);
aq.ajax(url, Bitmap.class, 0, cb);