0
私はAndroidアプリケーションの開発を始めました。私はネットワーキングに少し問題があります。私は、エラーをアップlookignてきたし、それはかなり一般的なようですAndroid - ネットワークを使用しようとすると、不明なエラーが発生する
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.client.ClientProtocolException;
import.org.apache.http.client.methods.HttpGet;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Menu extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DefaultHttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet("http://www.google.com");
try {
client.execute(method);
TextView t = (TextView) findViewById(R.id.myTextView);
t.setText("Ok");
} catch (ClientProtocolException e) {
TextView t = (TextView) findViewById(R.id.myTextView);
t.setText(e.getMessage());
} catch (IOException e) {
TextView t = (TextView) findViewById(R.id.myTextView);
t.setText(e.getMessage());
}
}
}
:私は、次のコードを実行した場合、私は、「不明なエラー」の例外メッセージが表示されます。エミュレータでのDNS解決に問題があります。しかし、エミュレータ上で問題なくブラウザを使用して、私が望む任意のWebサイトにアクセスできます。私はまた、ドメインを運のないIPアドレスに置き換えようとしました。
この問題を解決するにはどうすればよいですか?私はWindows Vistaを使用していて、ADTプラグインを使ってEclipseで開発しています。