Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am building a news application and I receive news in JSON format.
One of my friends recommended me to use Retrofit, but I did not understand why I should use Retrofit library instead of just handling Json with Gson myself.
Is there some advantage of Retrofit that I am not aware of?
Retrofit will save your development time, And also you can keep your code in developer friendly. Retrofit has given almost all the API's to make server call and to receive response. internally they also use GSON to do the parsing. you can go through this link you will get more info
http://vickychijwani.me/retrofit-vs-volley/
Developing your own type-safe HTTP library to interface with a REST API can be a real pain: you have to handle many aspects, such as making connections, caching, retrying failed requests, threading, response parsing, error handling, and more. Retrofit, on the other hand, is a well-planned, documented and tested library that will save you a lot of precious time and headaches.
Volley v/s Retrofit see this link
http://vickychijwani.me/retrofit-vs-volley/
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'// compulsory
compile 'com.squareup.retrofit2:converter-gson:2.1.0' //for retrofit conversion
Retrofit 2 is great networking library for modern Android apps, but each has its own strengths that is worth weighing for critical projects. Use Retrofit if your use-case is a standard REST API with JSON responses and not too many custom requirements in terms of caching, request prioritization, retries, etc.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am using Retrofit on Android to send a large file to a service, using a series of PUT requests. The code works (or appears to!), and now I want to add some unit tests. The file transmission is split into chunks and sent in multiple requests. I want my tests to capture the request body data and accumulate it all, then at the end I will verify the concatenated data chunks sent exactly matches the test file. This is to verify there are no off-by-one chunk boundary errors or overlaps and that kind of thing.
I have read about the Retrofit MockWebServer but in this case I don't care about mocking/processing the server response -- I only care about the request.
I know I can roll my own by adding an Interceptor to the OkHttpClient instance that Retrofit uses and doing the gathering/buffering myself, but it seems the kind of thing that people must have done before and I wondered if there is perhaps a different Mock server that supports this directly?
(Just to be super clear, I'm talking specifically about the request, not the response.)
See examples like https://stackoverflow.com/a/38525843/1542667
which use MockWebServer just as a way to access RecordedRequest
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I presently use volley for network calls.
But, Google doesn't seem to be actively maintaining volley.
I heard that google initially developed volley to use it for its play store app but they haven't mentioned it in their list of 3rd party libraries used.
Almost everyone uses Retrofit(looking at the benchmarks, Retrofit seems better option), is it time to quit using volley?
p.s: please don't post the pros and cons of volley and retrofit
Google doesn't seem to be actively maintaining volley
That depends entirely on how you define "actively maintaining". Development is ongoing, as you can see by looking at the Volley git repo, which shows many commits over the past year (as of the time of this writing).
Google also shipped an official Volley artifact earlier this year, as version 1.0.0.
but they haven't mentioned it in their list of 3rd party libraries used
Google wrote the Play Store app. Google wrote Volley. Hence, from Google's standpoint, Volley is not a third-party library. For anyone other than Google, Volley is a third-party library.
Almost everyone uses Retrofit
Retrofit is not equivalent to Volley. The triad of Square HTTP libraries (OkHttp3, Retrofit, Picasso) would be equivalent to Volley, and that combination exceeds Volley's capabilities.
Based on questions here at Stack Overflow, I do not believe that "almost everyone uses Retrofit".
is it time to quit using volley?
Nobody can answer that other than you. You are the one with decision criteria of importance to you. You are the one who needs to evaluate which libraries meet those criteria.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I know two of it can be used to send http request and get the response from the server, then we can parse into Json object if we want. So:
Which is the best way to send request and get response from the server, Retrofit 2 or HttpUrlConnection?
Which is advantage and disadvantage between them?
Retrofit 2 and Volley are both great networking libraries for modern Android apps, but each has its own strengths that are worth weighing for critical projects. Use Retrofit if your use-case is a standard REST API with JSON responses and not too many custom requirements in terms of caching, request prioritization, retries, etc. Use Volley if you have unusual / fine-grained requirements, or if you anticipate needing a lot of flexibility from your networking layer in the future at the cost of more code. Use neither if you're downloading large files or streaming -- for that, use DownloadManager instead.
Note: HttpClient is deprecated Now
Need More, Find it here
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am trying to implement a code which makes intial get/post request to fetch the data then using that data i m going to fetch download links with jsoup.
file are n't greater than 200 kbs
so which is better to do this task?
1)intial request
2)downloading files
How to chose between: Volley and Retrofit
If you are :
Making Requests then I would like to say though both frameworks are capable of the same outcome, Retrofit is capable of accomplishing this without customization. However, if you are implementing multiple requests within your application, and I suspect you are, customization may be necessary within Retrofit. Though that could be the case, at the simplest level Retrofit has the easier solution.
Downloading Files(Image): Being able to make file requests was a pretty large factor in the making of our decision. Volley comes packaged with a loader specifically designed to download images for you. Packaged along with the loader is a custom view called the NetworkImageView in which the developer only has to hand a URL and an ImageLoader to and Volley does the rest. This view is specifically targeted to work well with list views and allow for automatic cancellation of requests when the images parent view is destroyed. On the contrary, Retrofit does not easily support image downloads. To accomplish what we are able to with Volley, one would be required to download and include another library in your project such as Picasso. So here Volley is a better solution.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I want to load data from my API into custom gridview in my android application, my API return some text information and some image URL as JsonArray. I want to use retrofit and otto and picasso (for loading image), also I want asynchronous fetching.
The problem is I can't understand how to use this libraries together (also I can't understand Asynchronous implementation of retrofit). can you offer me some tutorial or example that I can understand the scenario ?
P.S: I read this post and wiki of this libraries, but can't understand well.
please give me some full tutorial or example. thanks in advance.
This is a good article and good introduction to retrofit, however his implementation is strange and works though.
You'll find a good example on how to use retrofit and otto on this repo: Flickr client
The API client using retrofit is in the async folder, please take time to understand, I remember it gave me a good hand with retrofit.
About Picasso you can see that later, this is gonna be handled later in your activity (or fragment) which has been register to the Otto bus. Picasso is just one line of code, you'll have more to do before with Retrofit and Otto :)