2012-03-01 14 views
0

REST Webサーバーに接続しようとしていますが、何が問題になるのか分かりません。接続しているコードは次のとおりです。ライン正しくデバッグウィンドウ上のHttpClient経由でWebサーバーに接続する

Log.i(TAG, Settings.getServiceUrl() + "/" + dia); 

プリント:

public List<Agenda> getAgenda(String dia) { 
    try { 
     Log.i(TAG, "It is inside getAgenda()"); 
     HttpClient client = new DefaultHttpClient(); 
     HttpGet method = new HttpGet(Settings.getServiceUrl() + "/" + dia); 
     Log.i(TAG, Settings.getServiceUrl() + "/" + dia); 
     //the line above prints: http://192.168.0.100/odonto/agenda.php/2012-02-01 
     HttpResponse resp = client.execute(method); 
     //return loadFromJSONArray(client.execute(method)); 
     Log.i(TAG, "Recebeu a response"); 
     return loadFromJSONArray(resp); 
    } catch (Exception e) { 
     e.printStackTrace(); 
     return null; 
    } 
} 

さて、ここでの事があります。しかし、行:

Log.i(TAG, "Recebeu a response"); 

は印刷されません。だから問題は次のとおりです:

HttpResponse resp = client.execute(method); 

しかし、私は本当にどうやって間違っているのか分かりません!!私はすでにFirefoxでRESTサーバーをテストしています。うまく動作します!ただタグをSystem.errを表示するためのフィルタとデバッグウィンドウは、リンクである:

enter image description here

答えて

1

あなたが許可拒否エラーを取得しています。アプリケーションタグの後にmenifestファイルに以下の許可を追加してください

<uses-permission android:name="android.permission.INTERNET"/> 
+0

私はラインを追加して、うまくいった!!それ以外のエラーが発生しましたが、接続が正常に機能しています。どうもありがとう... – trebew

関連する問題