Android: How get the status-code of an HttpClient request

后端 未结 2 507
感情败类
感情败类 2020-11-28 04:19

I want to download a file and need to check the response status code (ie HTTP /1.1 200 OK). This is a snipped of my code:

HttpGet httpRequest =          


        
相关标签:
2条回答
  • 2020-11-28 04:46

    This will return the int value:

    response.getStatusLine().getStatusCode()
    
    0 讨论(0)
  • 2020-11-28 04:52
    if (response.getStatusLine().getStatusCode()== HttpsURLConnection.HTTP_OK){
    ...
    }
    
    0 讨论(0)
提交回复
热议问题