Connecting to the Network on Android Devices

Networking on Android
Şubat 4, 2015
Managing Network Usage
Mart 11, 2015

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 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.

  • permission.INTERNET – to access the Internet
  • permission.ACCESS_NETWORK_STATE – to check the network state

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" />


Comments are closed.