I use the modification for http calls in an Android application and retrofit.client.UrlConnectionClient as a client when creating the adapter.
RestAdapter.Builder builder = new RestAdapter.Builder() .setEndpoint(url) .setLogLevel(RestAdapter.LogLevel.FULL) .setClient( new Client.Provider() { public Client get() { return new UrlConnectionClient() { @Override protected HttpURLConnection openConnection(Request request) throws IOException { HttpURLConnection connection = super.openConnection(request); connection.setConnectTimeout(connectionTimeout); return connection; }
I wanted to set a timeout to use UrlConnectionClient as my client. I could not find a way with other clients such as OkHttp.
Question: how can I cancel the current request?
I saw a similar entry @ Using Square's RetoFit Client, can I cancel the current request? If so, how? but my code will become really complicated if I try to add my own artists and try to cancel the request using this. I see if there is a slightly better way with my existing code.
I also see that Retorofit V2.0 has a Retry and Cancel plan, but I'm not sure when it will be released. https://github.com/square/retrofit/issues/297
Help is needed! In fact, I also need a way to repeat with the same code.
source share