Discussion:
[android-developers] OkHttp async calls: AsyncTask or OkHttp async api?
moby
2016-02-21 21:58:08 UTC
Permalink
Hello,

I am not so familiar with OkHttp library and I have some doubts on how it
should be used for async requests. I was using the android library for *http
*and I was using *asyncTask* for some request.

But since I wanted to try OkHttp library, I faced some "problem" on what is
the correct way it should be used.


Imagine you want to implement async request using OkHttp. I read that
OkHttp have it's own async api (
https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/AsynchronousGet.java
).


But then I came across this post (
http://stackoverflow.com/questions/26114299/squares-okhttp-download-progress)
in which the guy used the "old" asyncTask but with OkHttp request ( I also
found on other forums that people are using AsyncTask with OkHttp).


But OkHttp have its own async api, that's why is confsing for me,why people
continue to use AsyncTask.


*So my questions:*

1. What is the correct way to use async requests with OkHttp?
2. Is it a good practice to use AsyncTask with OkHTTP?
3. How I understood, both , Okhttp async api and AsyncTask can do
similar things. Then waht is the difference? why and in which cases should
I choose one instead of the other?


Thank you!

Cheers
--
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/989ace15-a330-4c06-9a25-81ce9fea2a66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TreKing
2016-02-22 22:56:26 UTC
Permalink
Post by moby
*So my questions:*
1. What is the correct way to use async requests with OkHttp?
2. Is it a good practice to use AsyncTask with OkHTTP?
3. How I understood, both , Okhttp async api and AsyncTask can do
similar things. Then waht is the difference? why and in which cases should
I choose one instead of the other?
Your questions are probably best suited to StackOverflow with the
appropriate tag, or an OkHTTP group or forum.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
--
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/CANCScghqHnX_LJ6hrDOS6Ho1SMZYBH%2B%3DWX4pjd2JMfzWcXdKcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...