Quick Links

Connecting to the Network on Android Devices
Apr 11, 2016

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


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.

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

 


Disclaimer
Terms And Conditions Of Use

All content provided on this IT Center blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site.

The owner of IT Center Blog will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.

This terms and conditions is subject to change at anytime with or without notice.