File tree Expand file tree Collapse file tree 2 files changed +47
-7
lines changed
src/com/loopj/android/http Expand file tree Collapse file tree 2 files changed +47
-7
lines changed Original file line number Diff line number Diff line change 33
33
34
34
/**
35
35
* Used to intercept and handle the responses from requests made using
36
- * {@link AsyncHttpClient}.
36
+ * {@link AsyncHttpClient}. The {@link #onSuccess(String)} method is
37
+ * designed to be anonymously overridden with your own response handling code.
37
38
* <p>
38
- * This class is designed to be passed to get, post, put and delete requests
39
- * with the {@link #onSuccess(String)} method anonymously overridden.
40
- * <p>
41
- * Optionally, you can also override the {@link #onFailure(Throwable)},
39
+ * Additionally, you can override the {@link #onFailure(Throwable)},
42
40
* {@link #onStart()}, and {@link #onFinish()} methods as required.
41
+ * <p>
42
+ * For example:
43
+ * <p>
44
+ * <pre>
45
+ * AsyncHttpClient client = new AsyncHttpClient("My User Agent");
46
+ * client.get("http://www.google.com", new AsyncHttpResponseHandler() {
47
+ * @Override
48
+ * public void onStart() {
49
+ * // Initiated the request
50
+ * }
51
+ *
52
+ * @Override
53
+ * public void onSuccess(String response) {
54
+ * // Successfully got a response
55
+ * }
56
+ *
57
+ * @Override
58
+ * public void onFailure(Throwable e) {
59
+ * // Response failed :(
60
+ * }
61
+ *
62
+ * @Override
63
+ * public void onFinish() {
64
+ * // Completed the request (either success or failure)
65
+ * }
66
+ * });
67
+ * </pre>
43
68
*/
44
69
public class AsyncHttpResponseHandler {
45
70
private static final int SUCCESS_MESSAGE = 0 ;
Original file line number Diff line number Diff line change 34
34
import org .apache .http .message .BasicNameValuePair ;
35
35
36
36
/**
37
- * A collection of string request parameters or files to send along with HTTP
38
- * GET, POST or PUT requests made with {@link AsyncHttpClient}.
37
+ * A collection of string request parameters or files to send along with
38
+ * requests made from an {@link AsyncHttpClient} instance.
39
+ * <p>
40
+ * For example:
41
+ * <p>
42
+ * <pre>
43
+ * RequestParams params = new RequestParams();
44
+ * params.put("username", "james");
45
+ * params.put("password", "123456");
46
+ * params.put("email", "my@email.com");
47
+ * params.put("profile_picture", new File("pic.jpg")); // Upload a File
48
+ * params.put("profile_picture2", someInputStream); // Upload an InputStream
49
+ * params.put("profile_picture3", new ByteArrayInputStream(someBytes)); // Upload some bytes
50
+ *
51
+ * AsyncHttpClient client = new AsyncHttpClient("My User Agent");
52
+ * client.post("http://myendpoint.com", params, responseHandler);
53
+ * </pre>
39
54
*/
40
55
public class RequestParams {
41
56
private static String ENCODING = "UTF-8" ;
You can’t perform that action at this time.
0 commit comments