FileNotFoundException when display google static map using Universal Image Loader

724 views Asked by At

My code:

  mapThumbUrl = "http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=13&size=1000x400&format=jpg&markers=40.714728,-73.998672";
  ImageLoader.getInstance().displayImage(mapThumbUrl, holder.image);

Exception:

http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=13&size=1000x400&format=jpg&markers=40.714728,-73.998672
java.io.FileNotFoundException: http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=13&size=1000x400&format=jpg&markers=40.714728,-73.998672
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
        at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromNetwork(BaseImageDownloader.java:122)
        at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:86)
        at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:93)
        at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:73)
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:264)
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:237)
        at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:135)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)

It seems google static map can be displayed in ImageView with AsyncTask as in this post: Use Google's Static Maps API to illustrate location in your Android apps

But I want to use UIL instead of AsyncTask since image handling is handed to UIL in my app.

Any clue on this?

1

There are 1 answers

0
Bin On BEST ANSWER

It works now even if no change on my code. I resize the static map to 100x40 and remove format param, it works and the url is like this: http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=13&size=100x40&markers=40.714728,-73.998672

However, when I add format param and restore size to 1000x400, it still work well. I guess it is was caused by my VPN? My Google Maps work well with my VPN when FileNotFoundException occurs.

I guess this question maybe helpful for developers in China.