请问请教如何从设备连接到开发机器?Android。如何从设备连接到开发机器?
我可以很容易地从模拟器做到这一点,但从设备我有连接超时异常。
这里是我的代码:
String hostname = "10.0.2.2";
int port = 4444;
Socket socket = null;
try{
socket = new Socket(InetAddress.getByName(hostname), port);
} catch(UnknownHostException e) {
Log.e("Capturer","UnknownHostException : " + e.getMessage(), e);
} catch(IOException e) {
Log.e("Capturer", "IOException : " + e.getMessage(), e);
}