botradingblog1 / android-kotlin-rest-okhttp-2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android Sample app for making REST calls with OkHttp and Kotlin Coroutines (Kotlin)

Overview

This project is a sample app for making REST calls with OkHttp and Kotlin Coroutines.

It contains:

  • Configuring your app for making REST calls by setting the internet permission
  • Uses OkHttp to make a Get call
  • Launches a HTTP request from a background thread using Kotlin coroutines
  • Uses ViewModel and LiveData to update the UI.

Supporting material

For a step-by-step tutorial, please see my blog post on making REST calls with OkHttp and Kotlin coroutines.

Getting Started

  1. Cone the project from GitHub
	https://github.com/justmobiledev/android-kotlin-rest-okhttp-2.git
  1. Build the project in AndroidStudio
  2. Deploy on simulator or device.

Versions used

  • Android Studio 4.1.1
  • Android API 29
  • OkHttp 4.9.0
  • view model and livedata 2.2.0
  • klaxon 5.0.1

Implementation

  • Configuring your app for making REST calls by setting the internet permission
  • Use OkHttp to make a Get call
  • Launch a HTTP request from a background thread using Kotlin coroutines
  • Use ViewModel and LiveData to update the UI.

Sample App Usage

  1. Select the 'Fetch' button to launch a Get request
  2. The response info is displayed in the MainActivity page

About

License:MIT License


Languages

Language:Kotlin 100.0%