I briefly explained the networking on Android in this post. Now I’ m going to explain how applications connect to the network on Android Devices.
Most of applications use HTTP protocol to talk to web servers. Android includes two different class for this. The main package to access network is java.net. In this package, there is a class for use network, which is HttpURLConnection. The second one is Apache HttpClient. Both of them also support HTTPS protocol, IPv6, upload and download but Android teams recommend HttpURLConnection for applications, which are targeted Gingerbread and upper level API.
Applications also requires permission to use network. There are two permission to use network.
Application Manifest file must contain those permissions as below code sample;
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />