0

我刚刚写了一个连接wifi的应用程序如下:

wifi.setWifiEnabled(false);
wifi.setWifiEnabled(true);

int res = wifi.addNetwork(wificonfigurationA);              
boolean b = false;
b = wifi.enableNetwork(res, true);
Log.d("WifiPreference", "enableNetwork returned " + b);

Socket socket = new Socket(serverAddr, 3000);
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);

out.println("Hey Server!");

这给出了01-02 00:03:36.882: E/ClientActivity(1550): java.net.ConnectException: /10.10.2.200:3000 - Network is unreachable错误。请帮忙

4

1 回答 1

0

使用 connectionManagaer 对象执行此操作,并始终在单独的线程中执行此类网络操作。

于 2013-04-23T04:28:47.700 回答