While doing Android development. There is really no clear way of doing network operations, sending and receiving data.

Currently I am handing it using HttpsURLConnection and having streams to build a request and response.

But I've seen on Android developers under Connectivity. Transmitting data using either Volley or Cronet.

I've created a test application using Volley and it seems straight forward. However Volley requires the Context to run meaning it's now attached to the Android Framework. So sticking with MVVM it doesn't really fit.

I have also read about headless Fragments which is a Fragment that contains an inline AsyncTask class to handle networking

I could continue using my HttpsURLConnection DataOutputStream and InputStreamReader. Then MVVM and unit testing can still work. There just doesn't seem like a standard way of doing this.

I am just looking to see if there is a more standard way of handling networking or not?

  • Any special reason for not using Retrofit? Dec 12, 2018 at 16:12
  • @rcosteira No specific reason. I actually haven't really heard of it before! I will have to check it out!
    – Derek
    Dec 12, 2018 at 22:58
  • It’ll probably solve your problem :) no Android stuff needed. You can isolate it completely. Let me know how it goes. Dec 12, 2018 at 23:52

1 Answer 1


I've been using URLConnection and building streams just like you, but it does seem discouraged by Google. For example, you need


To use HTTPURLConnection now (as of 8.0 I believe), which is a hassle when your application is sending benign junk. That was a random break I didn't need.

I still think streams, in an ASyncTask, are the way to go. You can use a third party library like Volley but you never know when Android is going to break it. At least if they break streams like in the above example, you can typically fix it quickly. They're never going to completely drop streams and ASyncTask.

  • Your application is never sending benign junk
    – user253751
    Sep 3, 2020 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.