【问题标题】:Unable to decode stream: java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)无法解码流:java.io.FileNotFoundException:打开失败:ENOENT(没有这样的文件或目录)
【发布时间】:2014-10-22 19:40:31
【问题描述】:

我正在尝试从 Google Map API 获取地点列表,但出现以下错误。

执行HttpResponse时抛出错误。

paramurl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?&location=[LAT],[LNG]&types=movie_theater&radius=5000&sensor=true&key=[API_KEY]"

我已经更正了上面的 url,现在错误已更改,我已将其发布在此代码 sn-p 下方。 [我从 ...json?&location... 中删除了 '&']。谢谢@323go。

   try {
        HttpClient httpClient = new DefaultHttpClient();
        HttpResponse httpResponse = httpClient.execute(new HttpGet(paramurl));
        int status = httpResponse.getStatusLine().getStatusCode();
        if (status == 200) {

            result = EntityUtils.toString(httpResponse.getEntity());
        }
    } catch (IOException e) {
        e.printStackTrace();
    **

}

这里是日志:

10-22 17:00:02.338  24247-24247/com.mussie.android.blocspot.blocspot E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: /51929ae149631b821866d0f99feccad0c41a8113: open failed: ENOENT (No such file or directory)
10-22 17:00:02.338  24247-24247/com.mussie.android.blocspot.blocspot D/AndroidRuntime﹕ Shutting down VM
10-22 17:00:02.348  24247-24247/com.mussie.android.blocspot.blocspot E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.mussie.android.blocspot.blocspot, PID: 24247
    java.lang.NullPointerException
            at com.google.j.a.cl.a(Unknown Source)
            at com.google.maps.api.android.lib6.c.cs.<init>(Unknown Source)
            at com.google.maps.api.android.lib6.c.cr.a(Unknown Source)
            at com.google.maps.api.android.lib6.c.ac.<init>(Unknown Source)
            at com.google.maps.api.android.lib6.c.ae.a(Unknown Source)
            at com.google.maps.api.android.lib6.c.dw.a(Unknown Source)
            at com.google.android.gms.maps.internal.l.onTransact(SourceFile:167)
            at android.os.Binder.transact(Binder.java:361)
            at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.addMarker(Unknown Source)
            at com.google.android.gms.maps.GoogleMap.addMarker(Unknown Source)
            at com.mussie.android.blocspot.blocspot.MapsActivity$GetPOIs.onPostExecute(MapsActivity.java:435)
            at com.mussie.android.blocspot.blocspot.MapsActivity$GetPOIs.onPostExecute(MapsActivity.java:380)
            at android.os.AsyncTask.finish(AsyncTask.java:632)
            at android.os.AsyncTask.access$600(AsyncTask.java:177)
            at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

**

【问题讨论】:

  • paramurl 是为了得到json格式的结果而发送的URL。我在浏览器中检查了 url,得到了 json 格式的所需数据。
  • paramurl的内容是什么?
  • @Duke,感谢您添加参数 url。您可以记录它(并对其进行消毒),以确保它是正确的吗? json?&amp;location 看起来也不正确。删除&amp; 并重试。

标签: java httpclient


【解决方案1】:

在查看了返回 json 结果的每一行代码后,我自己解决了这个问题。

  1. 我处理了所有检查服务器是否返回记录的方法(在本例中为 Google Map API)

  2. 我同时请求给定位置(商场、巴士站、餐馆等)的各种数据。由于我的代码没有优化,所以到处都是问题。

  3. 我做的第三件事也是最后一件事是清理清单文件(并确保我设置了所有权限)。

【讨论】:

  • 很好,现在请将此设置为您的答案(复选标记)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-23
  • 1970-01-01
  • 1970-01-01
  • 2013-04-29
相关资源
最近更新 更多