-1

Androidフォンをローカルマシンで実行されているサーバーにhttp経由で接続し、コンテンツを出力ストリームしようとしていますが、失敗しました..!

ここに私のコードがあります:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    try {

        URL url = new URL("http://192.168.24.42:80/DebugServer/");
        HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();     
        InputStream in = new BufferedInputStream(urlConnection.getInputStream());
        readStream(in);
        urlConnection.disconnect();

    } catch (IOException e) {
        e.printStackTrace();
}


private void readStream(InputStream in) {

    try {
        in.read();
        in.read();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
4

1 に答える 1