Retrofit-Lite for Android
Lightweight Secured HTTP client based on OKhttp and Retrofit.
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,
- Create model classes in POJO.
- Create a Retrofit instance.
- Define the API interfaces.
- Create callbacks on `enqueue`
- 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.
GET method with parameter
POST method with parameter
These methods are called with the process id which is given when initiated and the status code of the response.
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.
Retrofit-Lite for Android - Lightweight HTTP client based on OKhttp and Retrofit. Add the below dependency into your…
Enjoy your coffee :)