我用c#编写的Web服务及其工作正常 当我从我的Android代码中请求此服务时,它给我连接问题 我的代码看起来像这样
URL url;
try {
url = new URL("http://192.168.1.35/Audio.ashx");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
当我调试连接参数“connected = false”
时有什么建议吗?
答案 0 :(得分: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();
}
答案 1 :(得分:0)
的AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />