請問請教如何從設備連接到開發機器?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);
}