[Exception] Synchronous ResponseHandler used in AsyncHttpClient.

2020. 7. 7. 18:53개발자료/Android


반응형

Thread 내에서 AsyncHttpClient 사용시 예외 발생

 

 예외내용

java.lang.IllegalArgumentException: Synchronous ResponseHandler used in AsyncHttpClient. You should create your response handler in a looper thread or use SyncHttpClient instead.
     at com.loopj.android.http.AsyncHttpClient.sendRequest(AsyncHttpClient.java:1493)
     at com.loopj.android.http.AsyncHttpClient.get(AsyncHttpClient.java:1078)
     at com.loopj.android.http.AsyncHttpClient.get(AsyncHttpClient.java:1037)

 

 처리

AsyncHttpResponseHandler에 getUseSynchronousMode 메소드를 오버라이드 한다.

cliente.post(url, params, new AsyncHttpResponseHandler() {
	@Override
	public void onSuccess(int statusCode, Header[] headers, byte[] response) {
	}

	@Override
	public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
	}

	//-- You should create your response handler in a looper thread or use SyncHttpClient instead.
	//-- 대응코드
	@Override
	public boolean getUseSynchronousMode() {
		return false;
	}
});

 

 

 

 

반응형