Skip to content
Related Articles

Related Articles

How to Use Fast Android Networking Library in Android with Example?

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 18 Feb, 2022

In Android, we know multiple networking libraries like Retrofit, Volley. We use these libraries specifically for making networking requests like performing actions on API. But Besides that, there is another library called Fast Networking Library which has a few advantages over other libraries. In this tutorial, we will be specifically focusing on learning about this library. We will be doing the following.

  • Getting started with Fast Networking Library
  • Making a simple GET request 

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Add dependencies

Copy the following dependency and paste it into your app-level build.gradle file. 

implementation ‘

Step 3:  Add Internet permission in the manifest file

Make sure to add the following line of code in the Android Manifest File. which will give you access to using the internet, otherwise the app will crash.

<uses-permission android:name=”android.permission.INTERNET” />

Step 4: Adding TextView in activity_main.xml

For testing the working of our Fast Networking Library code we will need to add a text and change its text in order to make sure if we got a response successful or we got an error. So the code for activity_main.xml file is as below


<?xml version="1.0" encoding="utf-8"?>
        app:layout_constraintTop_toTopOf="parent" />

Step 5: Initializing the Android Networking Class

First, we have to initialize the Android Networking Class before we can use it. It can be done by adding a single line in MainActivity as follows


Step 6: Making a get request

We will try to fetch data from a REST API. The link for the API we will be using is given below

Add the following code in MainActivity which will actually make a GET request on the API

                .getAsJSONObject(new JSONObjectRequestListener() {
                    public void onResponse(JSONObject response) {
                        textView.setText("Response Successful");

                    public void onError(ANError anError) {
                        textView.setText("Response Failure");

Step 7: Working with the

After performing all the steps above our code in MainActivity will look like the code below. You can also directly copy the below code and paste it into your MainActivity file.


package com.example.gfgfastnetworkinglib;
import android.os.Bundle;
import android.widget.TextView;
import com.androidnetworking.AndroidNetworking;
import com.androidnetworking.error.ANError;
import com.androidnetworking.interfaces.JSONObjectRequestListener;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {
        // Defining TextView which we made in XML
        TextView textView = findViewById(;
        // Initializing Android Networking
        // Actually making the GET request
                .getAsJSONObject(new JSONObjectRequestListener() {
                    public void onResponse(JSONObject response) {
                        // Text will show success if Response is success
                        textView.setText("Response Successful");
                    public void onError(ANError anError) {
                        // Text will show failure if Response is failure
                        textView.setText("Response Failure");

Explanation of the above code:

We have to pass the API link inside the get() method of AndroidNetworking as you can see in the code above. As we proceed further we have two overridden methods onResponse and onError. Anyone one of both methods will get according to what response we get from the API. 

If the response is successful the onResponse method will get called and hence the text will get set to Response Successful, If we get failure Response from the API then the onError method will get called hence the code inside it will get executed and text will set to Response Unsuccessful. We may get a failure response because of some problem with the internet or some security issues with the API.


As we can clearly see the output shows Response Successful which means our GET request using Fast Networking is Successful. If Some problem would have occurred then in output we would see Response Failure.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!