ORAHTTPManager Class Reference
Inherits IORAHTTPManager.
Public Member Functions |
|
void | addRequest (ORARequest request, ORAHTTPResponseCallback responseCallback) |
Static Public Member Functions |
|
static synchronized ORAHTTPManager | getInstance (Context context) |
static synchronized ORAHTTPManager | getInstance () |
Detailed Description
ORAHTTPManager is singleton class which is useful to initiate any HTTP requests. All network activity generated should be funneled through this class.
Member Function Documentation
◆ addRequest()
void addRequest | ( | ORARequest | request, |
ORAHTTPResponseCallback | responseCallback | ||
) |
Initiates GET or POST request using ORARequest object. A callback will be provided upon completion of the request.
- Parameters
-
request The ORARequest object with all the necessary info. responseCallback A callback with data, response and error to be triggered when the request has finished.
Example:
findViewById(R.id.requestButton).setOnClickListener(new View.OnClickListener() {
publicvoid onClick(View v) {
// Create ORARequest object with necessary information:
ORARequest request = new ORARequest("http://YOUR_END_POINT");
request.setPayload("YOUR_PAYLOAD");
request.setTAG("YOUR_TAG");
request.addHeader("Content-Type", "application/json");
request.setRequestType(ORARequest.REQUEST_TYPE_POST)
// addRequest request to the Core HTTP Manager
ORAHTTPManager.getInstance(mContext).addRequest(request, new ORAHTTPResponseCallback() {
@Override
publicvoid onResponse(ORAResponse oraHTTPResponse) {
if (oraHTTPResponse.getResponseCode() < 0) {
// Something wrong...!
}
}
});
}
});
◆ getInstance() [1/2]
|
- Parameters
-
context Application context
- Returns
- Returns Singleton instance
- Deprecated:
- This method is deprecated. use getInstance() instead.
◆ getInstance() [2/2]
|
- Returns
- Returns Singleton instance
- ORAHTTPManager.java