2011-04-20 5 views
1

を拒否した私は、私の活動のコードの一部を持っている(私はエミュレータからこれを起動する)ロードファイル - 接続が

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    TextView txt=(TextView)this.findViewById(R.id.lbl); 
    try { 

      URL url = new URL("http://localhost/test.json"); 
      URLConnection urlconnection = url.openConnection(); 
      long l = urlconnection.getContentLength(); 

      BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); 
      String line; 
      StringBuffer buffer=new StringBuffer(); 
      while ((line = in.readLine()) != null) 
      { 
       buffer.append(line); 
      } 
      in.close(); 
      System.out.println("bufer="+buffer.toString()); 
      txt.setText(buffer.toString()); 


     } catch (Exception exc) { 

      exc.printStackTrace(); 

     } 
} 

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="test_android.test" 
     android:versionCode="1" 
     android:versionName="1.0"> 


    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".test_android" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 
    <uses-permission android:name="android.permission.INTERNET"></uses-permission> 
</manifest> 

のように私のマニフェストルックス私はWAMPサーバを持っているし、私のwwwディレクトリ内のtest.jsonですが、私はいつもCONNECTION REFUSEDというエラーが出ます。なにが問題ですか ?詳細については 、以下を参照してください:あなたのURLで

+0

localhostとのあなたコンピュータはAndroid-Device/Emulator上のローカルホストではありません! –

答えて

関連する問題