Android - Foursquare场地搜索错误:java.io.FileNotFoundException

时间:2013-02-03 12:53:41

标签: android httprequest foursquare filenotfoundexception

我正在尝试在我的Android应用中使用 Foursquare的搜索地点。我的URL必须正确,它在浏览器中正常工作,但在我的Android应用程序中,我得到一个IOException: java.io.FileNotFoundException 。 我想我的HTTP请求有问题,但我可以弄清楚是什么。你可以帮帮我吗?

new Thread() {
@Override 
public void run() {
    Looper.prepare();   

    try 
    {
        URL url = new URL(  FSQR_URL + 
                            "venues/search?ll=" + Float.toString(latitude) + "," + Float.toString(longitude) + 
                            "&client_id=" + FSQR_CLIENT_ID + 
                            "&client_secret=" + FSQR_CLIENT_SECRET + 
                            "&v=" + timeMilisToString(System.currentTimeMillis()));

        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.setDoInput(true);
        urlConnection.setDoOutput(true);
        urlConnection.connect();

        String responseBody     = streamToString(urlConnection.getInputStream());

        try 
        {
            JSONObject response1 = new JSONObject(responseBody);
            JSONObject response2 = new JSONObject(response1.getString("response"));
            setSearch(new JSONArray(response2.getString("venues")));
        } 
        catch (JSONException e) 
        {
            mResult.onError(e.toString());
        } 
    } 
    catch (ClientProtocolException e) 
    {
        mResult.onError(e.toString());   
    } 
    catch (IOException e) 
    {
        mResult.onError(e.toString());
    }   
}         

}开始();

0 个答案:

没有答案