Posts

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

Android GPS Location tracking User's current location.

Image
Android GPS Location can be used to track user's mobile current location and show in the app. In this blog, we’ll develop an application that fetches the user’s current location as Latitude and longitude programmatically. The project consists of a MainActivity.java class which displays a Get Location as Latitude and longitude and a PeriodicServcie .java Service class. Step:-1 The MainActivity.java class is defined below. package coders.androidkotlin.com.locationtracker; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.provider.Settings; import android.support.annotation. NonNull ; import android.support.v4.app.ActivityCompat; import android.support.v4.content.LocalBroadcastManage...

Using Kotlin JSON Parsing with Listview

In this post, we’ll learn how to parse JSON data using Moshi library.  What is Moshi? Moshi is an open source modern JSON library for both Android and Java, for parsing JSON. It is developed by Square (Jake and Jesse).It is like other JSON parsing libraries like Retrofit, GSON etc. Step 1 :- Adding Internet permissions to manifest.xml as Fallows in red:   <? xml version= "1.0" encoding= "utf-8" ?> < manifest xmlns: android = "http://schemas.android.com/apk/res/android" package= "com.example.ravi.jsonparseing" > < uses-permission android :name= "android.permission.INTERNET" /> < application android :allowBackup= "true" android :icon= "@mipmap/ic_launcher" android :label= "@string/app_name" android :roundIcon= "@mipmap/ic_launcher_round" android :supportsRtl= "true" android :theme= "@style...