Android HTTP Connection
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.
<uses-permission android:name="android.permission.INTERNET" />
So the manifest would follow this general construction
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.apis">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="MyApplication"
android:label="@string/application_title"
android:icon="@drawable/my_icon">
[ .. Your Activities go here ]
</application>
</manifest>
Eldelshell
Developing software since the age of 10 years old, my life has always revolved around software & technology in general. With a strong believe in open source software I have participated and developed several public projects. On the professional side I’ve been involved in many different projects, including development, systems, architecture and lately my focus has resided in web, mobile platforms and SOA architectures.
Updated on June 07, 2022Comments
-
Eldelshell almost 2 years
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