Use an AsyncTask to execute requests to the server, avoid all the boilerplate and use only some methods
In the file app/build.gradle add:
repositories{
maven { url "https://jitpack.io" }
}Then, in the dependencies add:
dependencies {
implementation 'com.github.G3rcar:HttpHandler:2.0.0'
}