![]() ServiceGenerator.create(FileDownloadService.class) ĭownloadService. Let's look at an example: FileDownloadService downloadService = ![]() This will return the complete request data. But the reason to include it is not so that you can reuse the call (hint: use clone()), it's that you can analyze the request that was made using call.request(). Thus, if the request was successful or even if it failed, you still can access the original Call object. Analyzing Requests With the Call ObjectĪs you've already seen, Retrofit 2 includes the Call instance to every callback method. This can be very useful if you need to send the same request multiple times. You cannot simply use the same object and call execute() or enqueue() again: FileDownloadService downloadService = ServiceGenerator.create(FileDownloadService.class) Ĭall originalCall = downloadService.downloadFileWithDynamicUrlSync(fileUrl) Ĭallback downloadCallback = new Callback() Simply sync your project to install all the dependencies. After adding the above dependencies in the dependencies section. Navigate to Gradle Scripts> adle file and in the dependencies section add below dependencies to use the retrofit library. One of the first things you've to know about the Call class and its instances: each instance is special made for one and only one request. Step 4 : Adding dependency for using Retrofit library in adle file. All the features we'll show you apply for all Retrofit requests. What kind of request it is, doesn't really matter. If you're interested in the details, give it a quick read. In this blog post, we'll make use of the code from our how to download files blog post.
0 Comments
Leave a Reply. |