Android停止执行http请求

时间:2017-08-09 13:21:17

标签: android http android-asynctask abstract

我想知道是否可以在http请求示例的responseReceived中停止执行Code:

new HttpRequest() {
        @Override
        public void onResponseReceived(JSONObject result) {
        // doing a lot of thing
        }
}.get("http://niceUrl");

在onResponseReceived中我做了很多事情(解析Json,将数据添加到列表等等)。

当我调用此功能时:

private void stopExecutionOfOnResponseReceived(){
    // I would like to stop the previous HttpRequest and launch a new One
}

HttpRequest是一个扩展的抽象类,扩展了AsyncTask String,Void,JSONObject

1 个答案:

答案 0 :(得分:1)

您可以使用中止方法。 此示例演示如何在正常完成之前中止HTTP方法。

    library(wdman) #I don't  know if this library is necessary
    library(RSelenium)

    selServ <- selenium(jvmargs = c("-Dwebdriver.chrome.verboseLogging=true"))
    remDr <- remoteDriver(port = 4567L, browserName = "chrome")
    remDr$open()

    ##From here you need to access with your login details inside the browser

    remDr$navigate(url)


    df=remDr$getPageSource()