Retrofit-Lite for Android — Lightweight HTTP client.

Retrofit-Lite for Android

Android developers know Retrofit is an awesome Type-safe HTTP client library that is developed for Android and Java by Square, Inc.

So If you are an Android developer you know how long the process is to configure Retrofit into your Android application whether you need to call single or multiple requests through the application.

List of usual Retrofit configurations to make HTTP calls,

  1. Create model classes in POJO.
  2. Create a Retrofit instance.
  3. Define the API interfaces.
  4. Create callbacks on `enqueue`
  5. Implement `onResponse` and `onFailure`

It’s a piece of a long process right? If you need to just call an API and get the response in String that’s it. Then here you have a solution that implements a powerful Retrofit HTTP client in a single line of Java code through Retrofit-Lite library.

Here Retrofit-Lite is a Hero.
It’s a lightweight more secure HTTP client library based on OKhttp and Retrofit.

To get this into your app, just add the below dependency into your Android module-level `build.gradle` file.

implementation ‘com.aslam:retrofit-lite:1.0.4’

Simple Usage
GET method with parameter

POST method with parameter

Response callbacks
These methods are called with the process id which is given when initiated and the status code of the response.

Advanced usage
Implement the `APITask.Listener` with the activity class or you can directly pass into the method.

A simple GET request with request headers

Basic authentication method with the header

Objects with POST request Serialize the object using GSON and implement the `APITask.Request` with the class.

Send the object to the request

Advanced Android developers can refer the Retrofit-Lite documentation to still go deeper on the library implementations such as,

  • Plain text on POST method
  • JSON text on POST method
  • Simple authentication method with the headers
  • POST method without any parameters
  • Custom timeout, default is 1 minute
  • Host verification
  • Synchronous HTTP requests

There is an awesome documentation to go deeper about this library and hit a star for the repository to remark your visit of satisfaction. Eventually, I’m the creator of the library so I appreciate your supports.

Thank you.

Enjoy your coffee :)

I’m Aslam Anver find me on GitHub and StackOverflow as aslamanver & Googlian

Passionate in AI Deep Learning, Find me on GitHub & StackOverflow

Passionate in AI Deep Learning, Find me on GitHub & StackOverflow