Can anybody tell my why this doesn’t work in the Android emulator? From the browser I have access and the server is internal. All I can think of is that I’m missing some configuration on my app so it can access the network layer.
try { InetAddress server = Inet4Address.getByName('thehost'); //Doesn't work either //or InetAddress server2 = Inet4Address.getByAddress(new String('192.168.1.30').getBytes()); if(server.isReachable(5000)){ Log.d(TAG, 'Ping!'); } Socket clientsocket = new Socket(server, 8080); } catch (UnknownHostException e) { Log.e(TAG, 'Server Not Found'); } catch (IOException e) { Log.e(TAG, 'Couldn't open socket'); }
Throws an UnknownHostException
Thanks
As far as configuration goes, the only setting you should need to access the Internet from your application is the INTERNET permission, enabled by adding the following line outside the Application tags within your application Manifest.
So the manifest would follow this general construction