[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4362":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":46,"readmeContent":47,"aiSummary":48,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":49,"discoverSource":50},4362,"Fast-Android-Networking","amitshekhariitbhu\u002FFast-Android-Networking","amitshekhariitbhu","🚀 A Complete Fast Android Networking Library that also supports HTTP\u002F2 🚀","https:\u002F\u002Foutcomeschool.com",null,"Java",5905,977,223,222,0,2,7,1,66.67,"Apache License 2.0",false,"master",true,[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45],"android","android-library","awesome","download","downloader","downloadmanager","fast","fast-android-networking","http","http-client","http2","https","internet","libraries","network","networking","okhttp","okhttpclient","rxjava","rxjava2","2026-06-12 04:00:22","\u003Cimg src=https:\u002F\u002Fraw.githubusercontent.com\u002Famitshekhariitbhu\u002FFast-Android-Networking\u002Fmaster\u002Fassets\u002Fandroidnetworking.png >\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:\u002F\u002Fsquare.github.io\u002Fokhttp\u002F).\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:\u002F\u002Fgithub.com\u002Fsquare\u002Fokio) , No more GC overhead in android applications.\n  [Okio](https:\u002F\u002Fgithub.com\u002Fsquare\u002Fokio) is made to handle GC overhead while allocating memory.\n  [Okio](https:\u002F\u002Fgithub.com\u002Fsquare\u002Fokio) does some clever things to save CPU and memory.\n* It uses [OkHttp](http:\u002F\u002Fsquare.github.io\u002Fokhttp\u002F) , more importantly it supports HTTP\u002F2.  \n\n## About me\n\nHi, I am Amit Shekhar, Founder @ [Outcome School](https:\u002F\u002Foutcomeschool.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\n### Follow Amit Shekhar\n\n- [X\u002FTwitter](https:\u002F\u002Ftwitter.com\u002Famitiitbhu)\n- [LinkedIn](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Famit-shekhar-iitbhu)\n- [GitHub](https:\u002F\u002Fgithub.com\u002Famitshekhariitbhu)\n\n### Follow Outcome School\n\n- [YouTube](https:\u002F\u002Fyoutube.com\u002F@OutcomeSchool)\n- [X\u002FTwitter](https:\u002F\u002Fx.com\u002Foutcome_school)\n- [LinkedIn](https:\u002F\u002Fwww.linkedin.com\u002Fcompany\u002Foutcomeschool)\n- [GitHub](http:\u002F\u002Fgithub.com\u002FOutcomeSchool)\n\n## I teach at Outcome School\n\n- [AI and Machine Learning](https:\u002F\u002Foutcomeschool.com\u002Fprogram\u002Fai-and-machine-learning)\n- [Android](https:\u002F\u002Foutcomeschool.com\u002Fprogram\u002Fandroid)\n\nJoin Outcome School and get a high-paying tech job: [Outcome School](https:\u002F\u002Foutcomeschool.com)\n\n## [Outcome School Blog](https:\u002F\u002Foutcomeschool.com\u002Fblog) - High-quality content to learn Android concepts.\n\n### RxJava2 Support, [check here](https:\u002F\u002Famitshekhariitbhu.github.io\u002FFast-Android-Networking\u002Frxjava2_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:\u002F\u002Famitshekhariitbhu.github.io\u002FFast-Android-Networking\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Famitshekhariitbhu\u002FFast-Android-Networking\u002Fmaster\u002Fassets\u002Fget_started.png\" width=\"150\" height=\"42\"\u002F>\u003C\u002Fa>\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:\u002F\u002Fjitpack.io' }\n```\n\nIf you are using `settings.gradle.kts`, add the following:\n```kotlin\nmaven { setUrl(\"https:\u002F\u002Fjitpack.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\" \u002F>\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:\u002F\u002Fsquare.github.io\u002Fokhttp\u002F) as networking layer, you can pass custom okHttpClient while initializing it.\n```java\n\u002F\u002F 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\u002F\u002F 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:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FgetAllUsers\u002F{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                      \u002F\u002F do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F handle error\n                    }\n                });                \n```\n### Making a POST Request\n```java\nAndroidNetworking.post(\"https:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FcreateAnUser\")\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                      \u002F\u002F do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F 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:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FcreateUser\")\n                 .addBodyParameter(user) \u002F\u002F 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                      \u002F\u002F do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F 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:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FcreateUser\")\n                 .addJSONObjectBody(jsonObject) \u002F\u002F posting json\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      \u002F\u002F do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F handle error\n                    }\n                });\n                \nAndroidNetworking.post(\"https:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FpostFile\")\n                 .addFileBody(file) \u002F\u002F 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                      \u002F\u002F do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F handle error\n                    }\n                });               \n```\n\n### Using it with your own JAVA Object - JSON Parser\n```java\n\u002F*--------------Example One -> Getting the userList----------------*\u002F\nAndroidNetworking.get(\"https:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FgetAllUsers\u002F{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>>() {\n                    @Override\n                    public void onResponse(List\u003CUser> users) {\n                      \u002F\u002F 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                     \u002F\u002F handle error\n                    }\n                });\n\u002F*--------------Example Two -> Getting an user----------------*\u002F\nAndroidNetworking.get(\"https:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FgetAnUserDetail\u002F{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener\u003CUser>() {\n                     @Override\n                     public void onResponse(User user) {\n                        \u002F\u002F 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                        \u002F\u002F handle error\n                     }\n                 }); \n\u002F*-- Note : YourObject.class, getAsObject and getAsObjectList are important here --*\u002F              \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                      \u002F\u002F do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      \u002F\u002F do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F 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                      \u002F\u002F do anything with progress \n                    }\n                 })\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      \u002F\u002F do anything with response                \n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F 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()) \u002F\u002F 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                      \u002F\u002F do anything with progress \n                    }\n                 })\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      \u002F\u002F below code will be executed in the executor provided\n                      \u002F\u002F do anything with response                \n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F 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) \u002F\u002F even if at the time of cancelling it will not cancel if 50% \n                 .build()                                 \u002F\u002F downloading is done.But can be cancalled with forceCancel.\n                 .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                      \u002F\u002F do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      \u002F\u002F do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F 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\"); \u002F\u002F All the requests with the given tag will be cancelled.\nAndroidNetworking.forceCancel(\"tag\");  \u002F\u002F All the requests with the given tag will be cancelled , even if any percent threshold is\n                                       \u002F\u002F set , it will be cancelled forcefully. \nAndroidNetworking.cancelAll(); \u002F\u002F All the requests will be cancelled.  \nAndroidNetworking.forceCancelAll(); \u002F\u002F All the requests will be cancelled , even if any percent threshold is\n                               \u002F\u002F 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\u002FimageView\"\n          android:layout_width=\"100dp\"\n          android:layout_height=\"100dp\"\n          android:layout_gravity=\"center\" \u002F>\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                    \u002F\u002F do anything with bitmap\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F handle error\n                    }\n                });\n```\n### Error Code Handling\n```java\npublic void onError(ANError error) {\n   if (error.getErrorCode() != 0) {\n        \u002F\u002F received error from server\n        \u002F\u002F error.getErrorCode() - the error code from server\n        \u002F\u002F error.getErrorBody() - the error body from server\n        \u002F\u002F 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        \u002F\u002F get parsed error object (If ApiError is your class)\n        ApiError apiError = error.getErrorAsObject(ApiError.class);\n   } else {\n        \u002F\u002F 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); \u002F\u002F remove a bitmap with key from LruCache\nAndroidNetworking.evictAllBitmap(); \u002F\u002F clear LruCache\n```\n### Prefetch a request (so that it can return from cache when required at instant)\n```java\nAndroidNetworking.get(\"https:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FgetAllUsers\u002F{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:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FgetAllUsers\u002F{pageNumber}\")\n                 .addPathParameter(\"pageNumber\", \"0\")\n                 .addQueryParameter(\"limit\", \"3\")\n                 .addHeaders(\"token\", \"1234\")\n                 .setTag(\"test\")\n                 .setPriority(Priority.LOW)\n                 .setOkHttpClient(okHttpClient) \u002F\u002F passing a custom okHttpClient \n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      \u002F\u002F do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                    \u002F\u002F 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      \u002F\u002F do anything with response\n    }\n    @Override\n    public void onError(ANError error) {\n      \u002F\u002F handle error\n    }\n});\n```\n### ConnectionClass Listener to get current network quality and bandwidth\n```java\n\u002F\u002F Adding Listener\nAndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {\n            @Override\n            public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {\n              \u002F\u002F do something on change in connectionQuality\n            }\n        });\n        \n\u002F\u002F Removing Listener   \nAndroidNetworking.removeConnectionQualityChangeListener();\n\n\u002F\u002F Getting current ConnectionQuality\nConnectionQuality connectionQuality = AndroidNetworking.getCurrentConnectionQuality();\nif(connectionQuality == ConnectionQuality.EXCELLENT) {\n  \u002F\u002F do something\n} else if (connectionQuality == ConnectionQuality.POOR) {\n  \u002F\u002F do something\n} else if (connectionQuality == ConnectionQuality.UNKNOWN) {\n  \u002F\u002F do something\n}\n\u002F\u002F Getting current bandwidth\nint currentBandwidth = AndroidNetworking.getCurrentBandwidth(); \u002F\u002F 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                      \u002F\u002F do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      \u002F\u002F do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      \u002F\u002F 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:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FgetAnUserDetail\u002F{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setUserAgent(\"getAnUser\")\n                .build()\n                .getAsOkHttpResponseAndParsed(new TypeToken\u003CUser>() {\n                }, new OkHttpResponseAndParsedRequestListener\u003CUser>() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, User user) {\n                      \u002F\u002F do anything with okHttpResponse and user\n                    }\n                    @Override\n                    public void onError(ANError anError) {\n                      \u002F\u002F handle error\n                    }\n                });\n```\n### Making Synchronous Request\n```java                \nANRequest request = AndroidNetworking.get(\"https:\u002F\u002Ffierce-cove-29863.herokuapp.com\u002FgetAllUsers\u002F{pageNumber}\")\n                        .addPathParameter(\"pageNumber\", \"0\")\n                        .addQueryParameter(\"limit\", \"3\")\n                        .build();\nANResponse\u003CList\u003CUser>> response = request.executeForObjectList(User.class);\nif (response.isSuccess()) {\n   List\u003CUser> users = responseTwo.getResult();\n} else {\n   \u002F\u002Fhandle 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(); \u002F\u002F simply enable logging\nAndroidNetworking.enableLogging(LEVEL.HEADERS); \u002F\u002F enabling logging with level\n```\n### Enabling GZIP From Client to Server\n```java\n\u002F\u002F Enabling GZIP for Request (Not needed if your server doesn't support GZIP Compression), anyway responses \n\u002F\u002F from server are automatically unGzipped if required. So enable it only if you need your request to be \n\u002F\u002F 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\u002FHTTPS 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:\u002F\u002Famitshekhariitbhu.github.io\u002FFast-Android-Networking\u002Frxjava2_support.html)\n\nAs it uses [OkHttp](http:\u002F\u002Fsquare.github.io\u002Fokhttp\u002F) as a networking layer, it supports:\n\n* Fast Android Networking Library supports HTTP\u002F2 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\u002F2 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:\u002F\u002Fsquare.github.io\u002Fokhttp\u002F) and [Okio](https:\u002F\u002Fgithub.com\u002Fsquare\u002Fokio), it is faster.\n* Single library for all type of networking.\n* Supports RxJava, RxJava2 -> [Check here](https:\u002F\u002Famitshekhariitbhu.github.io\u002FFast-Android-Networking\u002Frxjava2_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:\u002F\u002Fsquare.github.io\u002F) - As both [OkHttp](http:\u002F\u002Fsquare.github.io\u002Fokhttp\u002F) and [Okio](https:\u002F\u002Fgithub.com\u002Fsquare\u002Fokio)\n  used by Fast Android Networking is developed by [Square](https:\u002F\u002Fsquare.github.io\u002F).\n* [Volley](https:\u002F\u002Fandroid.googlesource.com\u002Fplatform\u002Fframeworks\u002Fvolley\u002F) - As Fast Android Networking uses ImageLoader that is developed by [Volley](https:\u002F\u002Fandroid.googlesource.com\u002Fplatform\u002Fframeworks\u002Fvolley\u002F).  \n* [Prashant Gupta](https:\u002F\u002Fgithub.com\u002FPrashantGupta17) - For RxJava, RxJava2 Support - [RxJava Support](https:\u002F\u002Fgithub.com\u002Famitshekhariitbhu\u002FFast-Android-Networking\u002Fwiki\u002FUsing-Fast-Android-Networking-Library-With-RxJava)\n\n### Contact - Let's become friend\n- [Twitter](https:\u002F\u002Ftwitter.com\u002Famitiitbhu)\n- [Github](https:\u002F\u002Fgithub.com\u002Famitshekhariitbhu)\n- [Medium](https:\u002F\u002Fmedium.com\u002F@amitshekhar)\n- [Facebook](https:\u002F\u002Fwww.facebook.com\u002Famit.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:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-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","Fast Android Networking 是一个用于Android应用中进行各种网络操作的高效库，支持HTTP\u002F2协议。它基于OkHttp网络层构建，提供了一站式的解决方案，包括请求发送、文件下载与上传、网络图片加载等，并且具有简单易用的接口来处理优先级设置、取消请求等功能。该库使用了Okio技术，有效减少了内存分配时的垃圾回收开销，提升了性能。适用于需要快速集成全面网络功能的Android开发项目，特别是那些寻求替代已过时HttpClient方案的应用。","2026-06-11 02:59:49","top_language"]