使用 Java 从 Android 向 Web 服务器发送和接收数据(POST 和 GET)的最佳方式?

Best way to send and receive data(POST and GET) from Android to web server using Java?

在我的 Android Studio 项目中,我使用 Java 并且我将 Room 数据库与 LiveData 和 ViewModel 相结合。

我想从 Room 数据库上传一些表格(向 PHP 脚本发出 post 请求)并且还能够下载(来自网络服务器的 GET 请求)。

我的问题是最好的方法是什么? 使用 Android Studio AsyncTask 是个好主意还是我应该使用 RxJava 进行网络调用以防止阻塞 UI? 我考虑使用 okHttp 来发送和接收数据。

对于 Android,有一些替代方案可以从您的应用程序发送 HTTP Rest 请求,但最简单易配置的是 Retrofit, this library allows to call to your Rest API from your Android App and you can Attach multiple configurations for Logging, Messaging, etc. Another library that you can use is RxJava