Android loopj Async Http crashes after 1.4.5 update

前端 未结 5 2103
谎友^
谎友^ 2021-02-04 05:35

The new update for Android loopj Async Http lib is out and they changed a lot. Now you need to manually set Looper.prepare() otherwise it uses synchronious mode ins

5条回答
  •  感动是毒
    2021-02-04 06:14

    I solve it with one code line

    I separated my responseHandler

    JsonHttpResponseHandler responseHandler = new JsonHttpResponseHandler(){
    
    
                @Override
                public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                    RecorridoResponseDTO respuesta= new Gson().fromJson(response.toString(), RecorridoResponseDTO.class);
                    recorrido.setRecorridoId(respuesta.getA());
                    mDataManager.actualizarRecorrido(recorrido);
                    try {
                        Thread.sleep(10000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
    
                }
    
    
                @Override
                public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
                    super.onFailure(statusCode, headers, throwable, errorResponse);
                }
    
    
            } ;
    

    and this was the holy line

    responseHandler.setUsePoolThread(true);
    

提交回复
热议问题