मैं अपने डेस्कटॉप पर एक प्रोग्राम से एम्यूलेटर पर एंड्रॉइड सर्वर तक पहुंचने में असमर्थ हूं, मैं इसे कैसे हल करूं?एंड्रॉइड सर्वर सॉकेट
कुछ (How to find LAN ip address of android device? से) कोड:
public static ArrayList<String> getSelfIP(){
try {
ArrayList<String> ipList = new ArrayList<>();
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
ipList.add(inetAddress.getHostAddress().toString());
}
}
}
return ipList;
} catch (SocketException ex) {}
return null;
}
परिणाम [fe80::5054:ff:fe12:3456%eth0, 10.0.2.15]
है क्या मैं कॉन्फ़िगर या एमुलेटर मेरे डेस्कटॉप कार्यक्रमों के द्वारा पहुंचा जा सकता बनाने के लिए क्या करना होगा?
मैं निम्नलिखित किया है: 50000:
> adb forward tcp:50000 tcp:50000
हालांकि, मैं स्थानीय होस्ट के माध्यम से सर्वर तक पहुँचने में असमर्थ हूँ।
इतना मुश्किल क्यों है? यहां देखें: http://developer.android.com/tools/devices/emulator.html लेकिन वास्तविक डिवाइस का उपयोग करना बहुत आसान है। – greenapps
मैंने अग्रेषण एडीबी कमांड के साथ प्रश्न अपडेट किया है, जो काम नहीं कर रहा है। – user3635998
आप कौन से आईपी और पोर्ट को एम्यूलेटर पर सर्वर से कनेक्ट करने के लिए उपयोग करते हैं? किस पोर्ट पर आपका सर्वर सुन रहा है? – greenapps