Posts

Showing posts from February, 2018

The Android Network connection Operations

Image
In this Networking tutorial, you will create a simple app which connects to the GitHub API to retrieve and display JSON responce. Here, we will learn about the following: How to check your network connection status. How to perform network operations. How to use open source libraries to perform network operations.   Required Permissions. Open AndroidManifest.xml , and add the following permissions just before the < application tag: < uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" /> < uses-permission android:name = "android.permission.INTERNET" />     Checking the Network Connection. Open MainActivity.java , and add the following method to the class: private boolean isNetworkConnected() { ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context. CONNECTIVITY_SERVICE ); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return networkInfo != null &a