Search code examples
androidandroid-studiovisual-studio-codeandroid-volleyapache-httpcomponents

Is Volley only available for Android?


I'm trying to write a Java code that makes HTTP requests that would run on both Windows and Android.

I'm given to understand that for Windows, Apache's HTTPComponents is used, and for Android Volley is used. But it appears neither work on the other platform.

Is there a library that works on both? Or a uniform API layer on one of them that based on the OS decides what to use?

I'm using VS Code for Windows and Android Studio for Android, both latest versions, if it is relevant.

Thanks in advance!


Solution

  • You can use Retrofit. According to the official website, Retrofit is a type-safe HTTP client for Java and Android which was developed by Square. With Retrofit, all you need to do is declare a Java interface to represent your API. Then, you can pass the API configuration to Retrofit, and you will get back a Java class implementation of your interface.