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
Related
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 2 years ago.
Improve this question
I am trying to create a mock response of an api call in an Android app.
Is Mockito the best way to go for that? I wanted to create a mock json of the actual api call
so that it I can test my app behaviour for different responses.
If you're really interested in mocking actual HTTP responses (response body, status codes, etc.), you should take a look at MockWebServer.
But in most cases, it makes more sense to use Mockito or Mockk (if you're using Kotlin) to mock responses from your local data sources like Repositories or Use Cases. So consider this approach if you have at least minimal wrapping logic around low-level networking stuff like OkHttp / Retrofit.
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.
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 6 years ago.
Improve this question
I quite new in Android developing platform (I'm frontender who has been using jQuery and now Angular2 (for 5 months) with RxJs ).
I used to code in core-Java in past for one year (6 years ago), so I'm little familiar with Java.
As I'm familiar with consuming REST API by using jQuery/Angular2 (which is really easy thing) I was wondering if there is any Android-framework to do that, or my only option is Retrofit, because I found it tangled to use.
Retrofit is your best choice if you want a direct mapping between api endpoints and Java Objects. You simply create DTOs and annotate each field with the corresponding json name.
Depending on the size and purpose of the api you may want to have a deeper control over what you send and receive, i.e. direct access to Request and Response objects. in this case, I recommend Volley library :-)
1) Retrofit use for best way coz its internally used OK HTTP .
2) Volley Used but retrofit is much better .
3) Client -server communication purpose made own HTTP Code .
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 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 8 years ago.
Improve this question
There are many frameworks to make http requests in Android, like Retrofit and Volley. But also, Android has its own classes to make this type of request, like HttpURLConnection and HttpClient
So what is the advantage of using some framework like these mentioned?
My doubt is if there is some big advantage in make requests using some framework, instead of using Android native classes.
The advantage is things like retries, restarts, threading & synchronization, and state management will be handled for you. This comes at the expense of configurability, but it's not a huge expense.