0

我有用 c# 编写的 Web 服务,当我从我的 android 代码中请求此服务时它运行良好,它给我的连接问题我的代码看起来像这样

 URL url;
try {
        url = new URL("http://192.168.1.35/Audio.ashx");
        HttpURLConnection connection = (HttpURLConnection)url.openConnection();

当我调试它时,连接参数“connected = false”

有什么建议么 ??

4

2 回答 2

0

AndroidManifest.xml

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

于 2013-09-26T09:17:18.260 回答
0

尝试从中获取输入流,然后可以这样获取数据:-

 URL url;
    try {
        url = new URL("http://www.mysite.se/index.asp?data=99");

        HttpURLConnection urlConnection = (HttpURLConnection) url
                .openConnection();

        InputStream in = urlConnection.getInputStream();

        InputStreamReader isw = new InputStreamReader(in);

        int data = isw.read();
        while (data != -1) {
            char current = (char) data;
            data = isw.read();
            System.out.print(current);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
于 2013-09-26T08:14:31.553 回答