|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Objectcom.baidu.sapi2.http.AsyncHttpResponseHandler
com.baidu.sapi2.http.BinaryHttpResponseHandler
public class BinaryHttpResponseHandler
Used to intercept and handle the responses from requests made using
AsyncHttpClient
. Receives response body as byte array with a
content-type whitelist. (e.g. checks Content-Type against allowed list,
Content-length).
For example:
AsyncHttpClient client = new AsyncHttpClient(); String[] allowedTypes = new String[] { "image/png" }; client.get("http://www.example.com/image.png", new BinaryHttpResponseHandler(allowedTypes) { @Override public void onSuccess(byte[] imageData) { // Successfully got a response } @Override public void onFailure(Throwable e, byte[] imageData) { // Response failed :( } });
字段摘要 |
---|
从类 com.baidu.sapi2.http.AsyncHttpResponseHandler 继承的字段 |
---|
FAILURE_MESSAGE, FINISH_MESSAGE, START_MESSAGE, SUCCESS_MESSAGE |
构造方法摘要 | |
---|---|
BinaryHttpResponseHandler()
Creates a new BinaryHttpResponseHandler |
|
BinaryHttpResponseHandler(String[] allowedContentTypes)
Creates a new BinaryHttpResponseHandler, and overrides the default allowed content types with passed String array (hopefully) of content types. |
方法摘要 | |
---|---|
protected void |
handleFailureMessage(Throwable e)
|
protected void |
handleMessage(android.os.Message msg)
|
protected void |
handleSuccessMessage(int statusCode,
byte[] responseBody)
|
void |
onFailure(Throwable error,
byte[] binaryData)
已过时。 |
void |
onSuccess(byte[] binaryData)
Fired when a request returns successfully, override to handle in your own code |
void |
onSuccess(int statusCode,
byte[] binaryData)
Fired when a request returns successfully, override to handle in your own code |
protected void |
sendFailureMessage(Throwable e,
byte[] responseBody)
|
protected void |
sendSuccessMessage(int statusCode,
byte[] responseBody)
|
从类 com.baidu.sapi2.http.AsyncHttpResponseHandler 继承的方法 |
---|
handleFailureMessage, handleSuccessMessage, obtainMessage, onFailure, onFailure, onFinish, onStart, onSuccess, onSuccess, sendFailureMessage, sendFinishMessage, sendMessage, sendStartMessage, sendSuccessMessage |
从类 java.lang.Object 继承的方法 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
构造方法详细信息 |
---|
public BinaryHttpResponseHandler()
public BinaryHttpResponseHandler(String[] allowedContentTypes)
方法详细信息 |
---|
public void onSuccess(byte[] binaryData)
binaryData
- the body of the HTTP response from the serverpublic void onSuccess(int statusCode, byte[] binaryData)
statusCode
- the status code of the responsebinaryData
- the body of the HTTP response from the serverpublic void onFailure(Throwable error, byte[] binaryData)
error
- the underlying cause of the failurebinaryData
- the response body, if anyprotected void sendSuccessMessage(int statusCode, byte[] responseBody)
protected void sendFailureMessage(Throwable e, byte[] responseBody)
AsyncHttpResponseHandler
中的 sendFailureMessage
protected void handleSuccessMessage(int statusCode, byte[] responseBody)
protected void handleFailureMessage(Throwable e)
protected void handleMessage(android.os.Message msg)
AsyncHttpResponseHandler
中的 handleMessage
|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |