• Latest Code...

    Featured Post

    Implementing Hilt in a Kotlin Android Jetpack Compose Project with MVVM Architecture

     In modern Android development, maintaining a scalable codebase can be challenging, especially when it comes to dependency management. Hilt,...

    How to use Retrofit to get data from stackoverflow API and GitHub Demo in android studio

    Retrofit is a type-safe REST client for Android developed by Square. The library provides a powerful framework for authenticating and interacting with APIs and sending network requests with OkHttp. See this guide to understand how OkHttp works.

    This library makes downloading JSON or XML data from a web API fairly straightforward. Once the data is downloaded then it is parsed into a Plain Old Java Object (POJO) which must be defined for each "resource" in the response.

    Setup
    Must be defined on internet permission on AndroidManifest.xml .


    Dependencies
    Add following dependencies on app/build.gradle file:



    Converter:
    Here is the different type of  Gson converter, we can use them:



    How to create retrofit instance, 
    then we have to define, the userendpoint:
    Now, create model class, user variables, In MainActivity.java, we have to create instance of APIClient and call the users.

    Download Full code: https://github.com/dharmakshetri/Android-API-Demos
    and you can find out Awesome Retrofit Article: Retrofit Tutorial With Example In Android Studio [Step by Step]
    More details:
    https://square.github.io/retrofit/
    https://github.com/square/retrofit
    https://guides.codepath.com/android/Consuming-APIs-with-Retrofit
    https://realm.io/news/droidcon-jake-wharton-simple-http-retrofit-2/
    http://www.vogella.com/tutorials/Retrofit/article.html


    Happy Coding !!!

    Contact Form

    Name

    Email *

    Message *