Timeout in DefaultHttpClient Class Android

前端 未结 2 2027
生来不讨喜
生来不讨喜 2020-12-16 01:28

I have created an Android application where I connect to a remote server php file to retrieve some information. Below is the code for that.

Here I want to add timeo

2条回答
  •  春和景丽
    2020-12-16 02:18

    Use the HttpConnectionParams of your DefaultHttpClient::

    final HttpParams httpParameters = yourHttpClient.getParams();
    
    HttpConnectionParams.setConnectionTimeout(httpParameters, connectionTimeOutSec * 1000);
    HttpConnectionParams.setSoTimeout        (httpParameters, socketTimeoutSec * 1000);
    

提交回复
热议问题