|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.loopj.android.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),
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) {
// Response failed :(
}
@Override
public void onFinish() {
// Completed the request (either success or failure)
}
});
| Constructor Summary | |
|---|---|
AsyncHttpResponseHandler()
Creates a new AsyncHttpResponseHandler |
|
| Method Summary | |
|---|---|
protected void |
handleFailureMessage(Throwable e)
|
protected void |
handleMessage(Message msg)
|
protected void |
handleSuccessMessage(String responseBody)
|
protected Message |
obtainMessage(int responseMessage,
Object response)
|
void |
onFailure(Throwable error)
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(String content)
Fired when a request returns successfully, override to handle in your own code |
protected void |
sendFailureMessage(Throwable e)
|
protected void |
sendFinishMessage()
|
protected void |
sendMessage(Message msg)
|
protected void |
sendStartMessage()
|
protected void |
sendSuccessMessage(String responseBody)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AsyncHttpResponseHandler()
| Method Detail |
|---|
public void onStart()
public void onFinish()
public void onSuccess(String content)
content - the body of the HTTP response from the serverpublic void onFailure(Throwable error)
error - the underlying cause of the failureprotected void sendSuccessMessage(String responseBody)
protected void sendFailureMessage(Throwable e)
protected void sendStartMessage()
protected void sendFinishMessage()
protected void handleSuccessMessage(String responseBody)
protected void handleFailureMessage(Throwable e)
protected void handleMessage(Message msg)
protected void sendMessage(Message msg)
protected Message obtainMessage(int responseMessage,
Object response)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||