|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Objectcom.baidu.sapi2.http.AsyncHttpResponseHandler
public class AsyncHttpResponseHandler
Used to intercept and handle the responses from requests made using
AsyncHttpClient
. The onSuccess(String)
method is designed to
be anonymously overridden with your own response handling code.
Additionally, you can override the onFailure(Throwable, String)
,
onStart()
, and onFinish()
methods as required.
For example:
AsyncHttpClient client = new AsyncHttpClient(); client.get("http://www.google.com", new AsyncHttpResponseHandler() { @Override public void onStart() { // Initiated the request } @Override public void onSuccess(String response) { // Successfully got a response } @Override public void onFailure(Throwable e, String response) { // Response failed :( } @Override public void onFinish() { // Completed the request (either success or failure) } });
字段摘要 | |
---|---|
protected static int |
FAILURE_MESSAGE
|
protected static int |
FINISH_MESSAGE
|
protected static int |
START_MESSAGE
|
protected static int |
SUCCESS_MESSAGE
|
构造方法摘要 | |
---|---|
AsyncHttpResponseHandler()
Creates a new AsyncHttpResponseHandler |
方法摘要 | |
---|---|
protected void |
handleFailureMessage(Throwable e,
String responseBody)
|
protected void |
handleMessage(android.os.Message msg)
|
protected void |
handleSuccessMessage(int statusCode,
String responseBody)
|
protected android.os.Message |
obtainMessage(int responseMessage,
Object response)
|
void |
onFailure(Throwable error)
已过时。 use onFailure(Throwable, String) |
void |
onFailure(Throwable error,
String content)
Fired when a request fails to complete, override to handle in your own code |
void |
onFinish()
Fired in all cases when the request is finished, after both success and failure, override to handle in your own code |
void |
onStart()
Fired when the request is started, override to handle in your own code |
void |
onSuccess(int statusCode,
String content)
Fired when a request returns successfully, override to handle in your own code |
void |
onSuccess(String content)
Fired when a request returns successfully, override to handle in your own code |
protected void |
sendFailureMessage(Throwable e,
byte[] responseBody)
|
protected void |
sendFailureMessage(Throwable e,
String responseBody)
|
protected void |
sendFinishMessage()
|
protected void |
sendMessage(android.os.Message msg)
|
protected void |
sendStartMessage()
|
protected void |
sendSuccessMessage(int statusCode,
String responseBody)
|
从类 java.lang.Object 继承的方法 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
字段详细信息 |
---|
protected static final int SUCCESS_MESSAGE
protected static final int FAILURE_MESSAGE
protected static final int START_MESSAGE
protected static final int FINISH_MESSAGE
构造方法详细信息 |
---|
public AsyncHttpResponseHandler()
方法详细信息 |
---|
public void onStart()
public void onFinish()
public void onSuccess(String content)
content
- the body of the HTTP response from the serverpublic void onSuccess(int statusCode, String content)
statusCode
- the status code of the responsecontent
- the body of the HTTP response from the serverpublic void onFailure(Throwable error)
onFailure(Throwable, String)
error
- the underlying cause of the failurepublic void onFailure(Throwable error, String content)
error
- the underlying cause of the failurecontent
- the response body, if anyprotected void sendSuccessMessage(int statusCode, String responseBody)
protected void sendFailureMessage(Throwable e, String responseBody)
protected void sendFailureMessage(Throwable e, byte[] responseBody)
protected void sendStartMessage()
protected void sendFinishMessage()
protected void handleSuccessMessage(int statusCode, String responseBody)
protected void handleFailureMessage(Throwable e, String responseBody)
protected void handleMessage(android.os.Message msg)
protected void sendMessage(android.os.Message msg)
protected android.os.Message obtainMessage(int responseMessage, Object response)
|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |