{"id":3565,"url":"https://github.com/amitshekhariitbhu/Fast-Android-Networking","last_synced_at":"2025-08-03T20:32:39.981Z","repository":{"id":43337728,"uuid":"54413435","full_name":"amitshekhariitbhu/Fast-Android-Networking","owner":"amitshekhariitbhu","description":"🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀","archived":false,"fork":false,"pushed_at":"2024-08-18T19:20:34.000Z","size":2856,"stargazers_count":5699,"open_issues_count":228,"forks_count":958,"subscribers_count":231,"default_branch":"master","last_synced_at":"2024-10-30T02:51:26.539Z","etag":null,"topics":["android","android-library","awesome","download","downloader","downloadmanager","fast","fast-android-networking","http","http-client","http2","https","internet","libraries","network","networking","okhttp","okhttpclient","rxjava","rxjava2"],"latest_commit_sha":null,"homepage":"https://outcomeschool.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amitshekhariitbhu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["amitshekhariitbhu"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2016-03-21T18:35:44.000Z","updated_at":"2024-10-29T10:03:34.000Z","dependencies_parsed_at":"2024-06-18T17:08:50.497Z","dependency_job_id":"1685ce40-61b9-489d-a089-4e420d8ff2cb","html_url":"https://github.com/amitshekhariitbhu/Fast-Android-Networking","commit_stats":{"total_commits":530,"total_committers":14,"mean_commits":"37.857142857142854","dds":0.07547169811320753,"last_synced_commit":"fb26f4bd399786735ece070c289fd0c7d831ed9c"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FFast-Android-Networking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FFast-Android-Networking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FFast-Android-Networking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FFast-Android-Networking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amitshekhariitbhu","download_url":"https://codeload.github.com/amitshekhariitbhu/Fast-Android-Networking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228567009,"owners_count":17937983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","awesome","download","downloader","downloadmanager","fast","fast-android-networking","http","http-client","http2","https","internet","libraries","network","networking","okhttp","okhttpclient","rxjava","rxjava2"],"created_at":"2024-01-05T20:16:45.104Z","updated_at":"2025-08-03T20:32:39.445Z","avatar_url":"https://github.com/amitshekhariitbhu.png","language":"Java","funding_links":["https://github.com/sponsors/amitshekhariitbhu"],"categories":["Networking","Library","HarmonyOS","Uncategorized","Libraries","Java","Android Debug Database is a powerful library for debugging databases and shared preferences in Android applications","Using Glide Bitmap Pool in your application","Android 开发中的日常积累"],"sub_categories":["Windows Manager","Uncategorized","Networking","Check out our other Open Source Projects","Check out another awesome library for fast and simple networking in Android.","安卓网络层(包含图片)"],"readme":"\u003cimg src=https://raw.githubusercontent.com/amitshekhariitbhu/Fast-Android-Networking/master/assets/androidnetworking.png \u003e\n\n# Fast Android Networking Library\n\n### About Fast Android Networking Library\n\nFast Android Networking Library is a powerful library for doing any type of networking in Android applications which is made on top of [OkHttp Networking Layer](http://square.github.io/okhttp/).\n\nFast Android Networking Library takes care of each and everything. So you don't have to do anything, just make request and listen for the response.\n\n### Why use Fast Android Networking ?\n* Recent removal of HttpClient in Android Marshmallow(Android M) made other networking libraries obsolete.\n* No other single library does each and everything like making request, downloading any type of file, uploading file, loading\n  image from network in ImageView, etc. There are some libraries but they are outdated.\n* No other library provides simple interface for doing all types of things in networking like setting priority, cancelling, etc.\n* As it uses [Okio](https://github.com/square/okio) , No more GC overhead in android applications.\n  [Okio](https://github.com/square/okio) is made to handle GC overhead while allocating memory.\n  [Okio](https://github.com/square/okio) does some clever things to save CPU and memory.\n* It uses [OkHttp](http://square.github.io/okhttp/) , more importantly it supports HTTP/2.  \n\n## About me\n\nHi, I am Amit Shekhar, Co-Founder @ [Outcome School](https://outcomeschool.com) • IIT 2010-14 • I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.\n\nYou can connect with me on:\n\n- [Twitter](https://twitter.com/amitiitbhu)\n- [YouTube](https://www.youtube.com/@amitshekhar)\n- [LinkedIn](https://www.linkedin.com/in/amit-shekhar-iitbhu)\n- [GitHub](https://github.com/amitshekhariitbhu)\n\n## [Outcome School Blog](https://outcomeschool.com/blog) - High-quality content to learn Android concepts.\n\n### RxJava2 Support, [check here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html).\n\n### Find this project useful ? :heart:\n* Support it by clicking the :star: button on the upper right of this page. :v:\n\nFor full details, visit the documentation on our web site :\n\n\u003ca href=\"https://amitshekhariitbhu.github.io/Fast-Android-Networking\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/amitshekhariitbhu/Fast-Android-Networking/master/assets/get_started.png\" width=\"150\" height=\"42\"/\u003e\u003c/a\u003e\n\n## Requirements\n\nFast Android Networking Library can be included in any Android application. \n\nFast Android Networking Library supports Android 2.3 (Gingerbread) and later. \n\n## Using Fast Android Networking Library in your application\n\nAdd this in your `settings.gradle`:\n```groovy\nmaven { url 'https://jitpack.io' }\n```\n\nIf you are using `settings.gradle.kts`, add the following:\n```kotlin\nmaven { setUrl(\"https://jitpack.io\") }\n```\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:1.0.4\")\n```\n\nDo not forget to add internet permission in manifest if already not present\n```xml\n\u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n```\nThen initialize it in onCreate() Method of application class :\n```java\nAndroidNetworking.initialize(getApplicationContext());\n```\nInitializing it with some customization , as it uses [OkHttp](http://square.github.io/okhttp/) as networking layer, you can pass custom okHttpClient while initializing it.\n```java\n// Adding an Network Interceptor for Debugging purpose :\nOkHttpClient okHttpClient = new OkHttpClient() .newBuilder()\n                        .addNetworkInterceptor(new StethoInterceptor())\n                        .build();\nAndroidNetworking.initialize(getApplicationContext(),okHttpClient);                        \n```\n\nUsing the Fast Android Networking with Jackson Parser\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:jackson-android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:jackson-android-networking:1.0.4\")\n```\n\n```java\n// Then set the JacksonParserFactory like below\nAndroidNetworking.setParserFactory(new JacksonParserFactory());\n```\n\nUsing the Fast Android Networking with RxJava2\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:rx2-android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:rx2-android-networking:1.0.4\")\n```\n\nUsing the Fast Android Networking with RxJava\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:rx-android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:rx-android-networking:1.0.4\")\n```\n\n### Making a GET Request\n```java\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                 .addPathParameter(\"pageNumber\", \"0\")\n                 .addQueryParameter(\"limit\", \"3\")\n                 .addHeaders(\"token\", \"1234\")\n                 .setTag(\"test\")\n                 .setPriority(Priority.LOW)\n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });                \n```\n### Making a POST Request\n```java\nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/createAnUser\")\n                 .addBodyParameter(\"firstname\", \"Amit\")\n                 .addBodyParameter(\"lastname\", \"Shekhar\")\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n```\nYou can also post java object, json, file, etc in POST request like this.\n```java\nUser user = new User();\nuser.firstname = \"Amit\";\nuser.lastname = \"Shekhar\";\n\nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/createUser\")\n                 .addBodyParameter(user) // posting java object\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n\n\nJSONObject jsonObject = new JSONObject();\ntry {\n    jsonObject.put(\"firstname\", \"Amit\");\n    jsonObject.put(\"lastname\", \"Shekhar\");\n} catch (JSONException e) {\n  e.printStackTrace();\n}\n       \nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/createUser\")\n                 .addJSONObjectBody(jsonObject) // posting json\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n                \nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/postFile\")\n                 .addFileBody(file) // posting any type of file\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });               \n```\n\n### Using it with your own JAVA Object - JSON Parser\n```java\n/*--------------Example One -\u003e Getting the userList----------------*/\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener\u003cList\u003cUser\u003e\u003e() {\n                    @Override\n                    public void onResponse(List\u003cUser\u003e users) {\n                      // do anything with response\n                      Log.d(TAG, \"userList size : \" + users.size());\n                      for (User user : users) {\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                      }\n                    }\n                    @Override\n                    public void onError(ANError anError) {\n                     // handle error\n                    }\n                });\n/*--------------Example Two -\u003e Getting an user----------------*/\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUserDetail/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener\u003cUser\u003e() {\n                     @Override\n                     public void onResponse(User user) {\n                        // do anything with response\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                     }\n                     @Override\n                     public void onError(ANError anError) {\n                        // handle error\n                     }\n                 }); \n/*-- Note : YourObject.class, getAsObject and getAsObjectList are important here --*/              \n```\n\n### Downloading a file from server\n```java\nAndroidNetworking.download(url,dirPath,fileName)\n                 .setTag(\"downloadTest\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                      // do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      // do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error    \n                    }\n                });                 \n```\n### Uploading a file to server\n```java\nAndroidNetworking.upload(url)\n                 .addMultipartFile(\"image\",file)    \n                 .addMultipartParameter(\"key\",\"value\")\n                 .setTag(\"uploadTest\")\n                 .setPriority(Priority.HIGH)\n                 .build()\n                 .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                      // do anything with progress \n                    }\n                 })\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // do anything with response                \n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error \n                    }\n                 }); \n```\n\n### Getting Response and completion in an another thread executor \n(Note : Error and Progress will always be returned in main thread of application)\n```java\nAndroidNetworking.upload(url)\n                 .addMultipartFile(\"image\",file)  \n                 .addMultipartParameter(\"key\",\"value\")  \n                 .setTag(\"uploadTest\")\n                 .setPriority(Priority.HIGH)\n                 .build()\n                 .setExecutor(Executors.newSingleThreadExecutor()) // setting an executor to get response or completion on that executor thread\n                 .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                      // do anything with progress \n                    }\n                 })\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // below code will be executed in the executor provided\n                      // do anything with response                \n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error \n                    }\n                 }); \n```\n### Setting a Percentage Threshold For Not Cancelling the request if it has completed the given threshold\n```java\nAndroidNetworking.download(url,dirPath,fileName)\n                 .setTag(\"downloadTest\")\n                 .setPriority(Priority.MEDIUM)\n                 .setPercentageThresholdForCancelling(50) // even if at the time of cancelling it will not cancel if 50% \n                 .build()                                 // downloading is done.But can be cancalled with forceCancel.\n                 .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                      // do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      // do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error    \n                    }\n                });   \n```\n### Cancelling a request.\nAny request with a given tag can be cancelled. Just do like this.\n```java\nAndroidNetworking.cancel(\"tag\"); // All the requests with the given tag will be cancelled.\nAndroidNetworking.forceCancel(\"tag\");  // All the requests with the given tag will be cancelled , even if any percent threshold is\n                                       // set , it will be cancelled forcefully. \nAndroidNetworking.cancelAll(); // All the requests will be cancelled.  \nAndroidNetworking.forceCancelAll(); // All the requests will be cancelled , even if any percent threshold is\n                               // set , it will be cancelled forcefully.                           \n```\n### Loading image from network into ImageView\n```xml\n      \u003ccom.androidnetworking.widget.ANImageView\n          android:id=\"@+id/imageView\"\n          android:layout_width=\"100dp\"\n          android:layout_height=\"100dp\"\n          android:layout_gravity=\"center\" /\u003e\n          \n      imageView.setDefaultImageResId(R.drawable.default);\n      imageView.setErrorImageResId(R.drawable.error);\n      imageView.setImageUrl(imageUrl);          \n```\n### Getting Bitmap from url with some specified parameters\n```java\nAndroidNetworking.get(imageUrl)\n                 .setTag(\"imageRequestTag\")\n                 .setPriority(Priority.MEDIUM)\n                 .setBitmapMaxHeight(100)\n                 .setBitmapMaxWidth(100)\n                 .setBitmapConfig(Bitmap.Config.ARGB_8888)\n                 .build()\n                 .getAsBitmap(new BitmapRequestListener() {\n                    @Override\n                    public void onResponse(Bitmap bitmap) {\n                    // do anything with bitmap\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n```\n### Error Code Handling\n```java\npublic void onError(ANError error) {\n   if (error.getErrorCode() != 0) {\n        // received error from server\n        // error.getErrorCode() - the error code from server\n        // error.getErrorBody() - the error body from server\n        // error.getErrorDetail() - just an error detail\n        Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n        Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n        Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n        // get parsed error object (If ApiError is your class)\n        ApiError apiError = error.getErrorAsObject(ApiError.class);\n   } else {\n        // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n        Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n   }\n}\n```\n### Remove Bitmap from cache or clear cache\n```java\nAndroidNetworking.evictBitmap(key); // remove a bitmap with key from LruCache\nAndroidNetworking.evictAllBitmap(); // clear LruCache\n```\n### Prefetch a request (so that it can return from cache when required at instant)\n```java\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"30\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .prefetch();\n```\n### Customizing OkHttpClient for a particular request\n```java\nOkHttpClient okHttpClient = new OkHttpClient().newBuilder()\n                .addInterceptor(new GzipRequestInterceptor())\n                .build();\n                \nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                 .addPathParameter(\"pageNumber\", \"0\")\n                 .addQueryParameter(\"limit\", \"3\")\n                 .addHeaders(\"token\", \"1234\")\n                 .setTag(\"test\")\n                 .setPriority(Priority.LOW)\n                 .setOkHttpClient(okHttpClient) // passing a custom okHttpClient \n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                    // handle error\n                    }\n                });\n```\n### Making a conditional request (Building a request)\n```java\nANRequest.GetRequestBuilder getRequestBuilder = new ANRequest.GetRequestBuilder(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n               \nif(isHeaderRequired){\n getRequestBuilder.addHeaders(\"token\", \"1234\");\n}\n\nif(executorRequired){\n getRequestBuilder.setExecutor(Executors.newSingleThreadExecutor());\n}\n               \nANRequest anRequest = getRequestBuilder.build();       \n                 \nanRequest.getAsJSONObject(new JSONObjectRequestListener() {\n    @Override\n    public void onResponse(JSONObject response) {\n      // do anything with response\n    }\n    @Override\n    public void onError(ANError error) {\n      // handle error\n    }\n});\n```\n### ConnectionClass Listener to get current network quality and bandwidth\n```java\n// Adding Listener\nAndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {\n            @Override\n            public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {\n              // do something on change in connectionQuality\n            }\n        });\n        \n// Removing Listener   \nAndroidNetworking.removeConnectionQualityChangeListener();\n\n// Getting current ConnectionQuality\nConnectionQuality connectionQuality = AndroidNetworking.getCurrentConnectionQuality();\nif(connectionQuality == ConnectionQuality.EXCELLENT) {\n  // do something\n} else if (connectionQuality == ConnectionQuality.POOR) {\n  // do something\n} else if (connectionQuality == ConnectionQuality.UNKNOWN) {\n  // do something\n}\n// Getting current bandwidth\nint currentBandwidth = AndroidNetworking.getCurrentBandwidth(); // Note : if (currentBandwidth == 0) : means UNKNOWN\n```\n### Getting Analytics of a request by setting AnalyticsListener on that\n```java\nAndroidNetworking.download(url,dirPath,fileName)\n                 .setTag(\"downloadTest\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .setAnalyticsListener(new AnalyticsListener() {\n                      @Override\n                      public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                          Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                          Log.d(TAG, \" bytesSent : \" + bytesSent);\n                          Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                          Log.d(TAG, \" isFromCache : \" + isFromCache);\n                      }\n                  })\n                 .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                      // do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      // do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error    \n                    }\n                });  \nNote : If bytesSent or bytesReceived is -1 , it means it is unknown                \n```\n### Getting OkHttpResponse in Response\n```java\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUserDetail/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setUserAgent(\"getAnUser\")\n                .build()\n                .getAsOkHttpResponseAndParsed(new TypeToken\u003cUser\u003e() {\n                }, new OkHttpResponseAndParsedRequestListener\u003cUser\u003e() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, User user) {\n                      // do anything with okHttpResponse and user\n                    }\n                    @Override\n                    public void onError(ANError anError) {\n                      // handle error\n                    }\n                });\n```\n### Making Synchronous Request\n```java                \nANRequest request = AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                        .addPathParameter(\"pageNumber\", \"0\")\n                        .addQueryParameter(\"limit\", \"3\")\n                        .build();\nANResponse\u003cList\u003cUser\u003e\u003e response = request.executeForObjectList(User.class);\nif (response.isSuccess()) {\n   List\u003cUser\u003e users = responseTwo.getResult();\n} else {\n   //handle error\n}                                        \n```\n### How caching works ?\n* First of all the server must send cache-control in header so that is starts working.\n* Response will be cached on the basis of cache-control max-age,max-stale.\n* If internet is connected and the age is NOT expired it will return from cache.\n* If internet is connected and the age is expired and if server returns 304(NOT MODIFIED) it will return from cache.\n* If internet is NOT connected if you are using getResponseOnlyIfCached() - it will return from cache even it date is expired.\n* If internet is NOT connected , if you are NOT using getResponseOnlyIfCached() - it will NOT return anything.\n* If you are using getResponseOnlyFromNetwork() , it will only return response after validation from server.\n* If cache-control is set, it will work according to the max-age,max-stale returned from server.\n* If internet is NOT connected only way to get cache Response is by using getResponseOnlyIfCached().\n\n### Enabling Logging\n```java\nAndroidNetworking.enableLogging(); // simply enable logging\nAndroidNetworking.enableLogging(LEVEL.HEADERS); // enabling logging with level\n```\n### Enabling GZIP From Client to Server\n```java\n// Enabling GZIP for Request (Not needed if your server doesn't support GZIP Compression), anyway responses \n// from server are automatically unGzipped if required. So enable it only if you need your request to be \n// Gzipped before sending to server(Make sure your server support GZIP Compression).\nOkHttpClient okHttpClient = new OkHttpClient().newBuilder()\n                .addInterceptor(new GzipRequestInterceptor())\n                .build();\nAndroidNetworking.initialize(getApplicationContext(),okHttpClient);                \n```\n### IMPORTANT NOTE\n* Use IMMEDIATE Priority with caution - use is at appropriate place only when\n  1 or 2 (at max 2)IMMEDIATE request is required at instant.Otherwise use HIGH Priority.\n* Known Bug : As present if you are using GZIP Interceptor from client to server, Upload progress\n  is not working perfectly in Multipart.\n  \n  If you are using Proguard with Gradle build system (which is usually the case), you don't have to do anything. The appropriate Proguard rules will be automatically applied. If you still need the rules applied in `proguard-rules.pro`, it is as follows:\n  ```\n  -dontwarn okio.**\n  ```\n\n  \n### Fast Android Networking Library supports\n\n* Fast Android Networking Library supports all types of HTTP/HTTPS request like GET, POST, DELETE, HEAD, PUT, PATCH\n* Fast Android Networking Library supports downloading any type of file\n* Fast Android Networking Library supports uploading any type of file (supports multipart upload)\n* Fast Android Networking Library supports cancelling a request\n* Fast Android Networking Library supports setting priority to any request (LOW, MEDIUM, HIGH, IMMEDIATE)\n* Fast Android Networking Library supports [RxJava](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html)\n\nAs it uses [OkHttp](http://square.github.io/okhttp/) as a networking layer, it supports:\n\n* Fast Android Networking Library supports HTTP/2 support allows all requests to the same host to share a socket\n* Fast Android Networking Library uses connection pooling which reduces request latency (if HTTP/2 isn’t available)\n* Transparent GZIP shrinks download sizes\n* Fast Android Networking Library supports response caching which avoids the network completely for repeat requests\n\n### Difference over other Networking Library\n* In Fast Android Networking Library, OkHttpClient can be customized for every request easily — like timeout customization, etc. for each request.\n* As Fast Android Networking Library uses [OkHttp](http://square.github.io/okhttp/) and [Okio](https://github.com/square/okio), it is faster.\n* Single library for all type of networking.\n* Supports RxJava, RxJava2 -\u003e [Check here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html)\n* Current bandwidth and connection quality can be obtained to decide logic of code.\n* Executor can be passed to any request to get the response in another thread.\n* Complete analytics of any request can be obtained.\n* All types of customization are possible.\n* Immediate Request really is immediate now.\n* Prefetching of any request can be done so that it gives instant data when required from the cache.\n* Proper request canceling.\n* Prevents cancellation of a request if it’s completed more than a specific threshold percentage.\n* A simple interface to make any type of request.\n* Proper Response Caching — which leads to reduced bandwidth usage. \n\n### TODO\n* Integration with other library\n* And of course many many features and bug fixes\n\n### CREDITS\n* [Square](https://square.github.io/) - As both [OkHttp](http://square.github.io/okhttp/) and [Okio](https://github.com/square/okio)\n  used by Fast Android Networking is developed by [Square](https://square.github.io/).\n* [Volley](https://android.googlesource.com/platform/frameworks/volley/) - As Fast Android Networking uses ImageLoader that is developed by [Volley](https://android.googlesource.com/platform/frameworks/volley/).  \n* [Prashant Gupta](https://github.com/PrashantGupta17) - For RxJava, RxJava2 Support - [RxJava Support](https://github.com/amitshekhariitbhu/Fast-Android-Networking/wiki/Using-Fast-Android-Networking-Library-With-RxJava)\n\n### Contact - Let's become friend\n- [Twitter](https://twitter.com/amitiitbhu)\n- [Github](https://github.com/amitshekhariitbhu)\n- [Medium](https://medium.com/@amitshekhar)\n- [Facebook](https://www.facebook.com/amit.shekhar.iitbhu)\n\n### License\n```\n   Copyright (C) 2024 Amit Shekhar\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n\n### Contributing to Fast Android Networking\nAll pull requests are welcome, make sure to follow the [contribution guidelines](CONTRIBUTING.md)\nwhen you submit pull request.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitshekhariitbhu%2FFast-Android-Networking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famitshekhariitbhu%2FFast-Android-Networking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitshekhariitbhu%2FFast-Android-Networking/lists"}