public class FH extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
LOG_LEVEL_DEBUG |
static int |
LOG_LEVEL_ERROR |
static int |
LOG_LEVEL_INFO |
static int |
LOG_LEVEL_NONE |
static int |
LOG_LEVEL_VERBOSE |
static int |
LOG_LEVEL_WARNING |
static String |
VERSION |
| Modifier and Type | Method and Description |
|---|---|
static FHActRequest |
buildActRequest(String pRemoteAction,
JSONObject pParams)
Deprecated.
|
static FHAuthRequest |
buildAuthRequest()
Builds an instance of FHAuthRequest object to perform an authentication request.
|
static FHAuthRequest |
buildAuthRequest(String pPolicyId)
Builds an instance of FHAuthRequest object to perform an authentication request with an auth policy id set.
|
static FHAuthRequest |
buildAuthRequest(String pPolicyId,
String pUserName,
String pPassword)
Builds an instance of FHAuthRequest to perform an authentication request with an auth policy id,
user name, and password set.
|
static FHCloudRequest |
buildCloudRequest(String pPath,
String pMethod,
cz.msebera.android.httpclient.Header[] pHeaders,
JSONObject pParams)
Builds an instance of FHCloudRequest to call cloud APIs.
|
static void |
cloud(String pPath,
String pMethod,
cz.msebera.android.httpclient.Header[] pHeaders,
JSONObject pParams,
FHActCallback pCallback)
Calls cloud APIs asynchronously.
|
static String |
getCloudHost()
Gets the cloud host.
|
static JSONObject |
getDefaultParams()
Gets the default params for customised HTTP Requests.
|
static cz.msebera.android.httpclient.Header[] |
getDefaultParamsAsHeaders(cz.msebera.android.httpclient.Header[] pHeaders)
Similar to
getDefaultParams, but returns HTTP headers instead. |
static int |
getLogLevel()
Gets the current log level for the FH library.
|
static String |
getUserAgent()
Gets the customized user-agent string for the SDK.
|
static void |
init(android.content.Context pContext,
FHActCallback pCallback)
Initializes the application.
|
static boolean |
isOnline() |
static boolean |
isReady()
Checks if FH is ready.
|
static void |
pushRegister(FHActCallback pCallback)
Registers a device on a push network.
|
static void |
pushRegister(PushConfig pPushConfig,
FHActCallback pCallback)
Registers a device on a push network.
|
static void |
sendPushMetrics(String pMessageId,
FHActCallback pCallback)
Sends confirmation a message was opened.
|
static void |
setLogLevel(int pLogLevel)
Sets the log level for the library.
|
static void |
stop() |
public static final int LOG_LEVEL_VERBOSE
public static final int LOG_LEVEL_DEBUG
public static final int LOG_LEVEL_INFO
public static final int LOG_LEVEL_WARNING
public static final int LOG_LEVEL_ERROR
public static final int LOG_LEVEL_NONE
public static final String VERSION
public static void init(android.content.Context pContext,
FHActCallback pCallback)
FH.init(this, new FHActCallback() {
public void success(FHResponse pRes) {
//pRes will be null for init call if it succeeds, don't use it to access response data
FHActRequest request = FH.buildActRequest("readData", new JSONObject());
request.executeAsync(new FHActCallback(){
public void success(FHResponse pResp){
//process response data
}
public void fail(FHResponse pResp){
//process error data
}
})
}
public void fail(FHResponse pRes) {
Log.e("FHInit", pRes.getErrorMessage(), pRes.getError());
}
});
pContext - your application's contextpCallback - the callback function to be executed after initialization is finishedpublic static boolean isOnline()
public static void stop()
public static boolean isReady()
@Deprecated public static FHActRequest buildActRequest(String pRemoteAction, JSONObject pParams) throws FHNotReadyException
FHNotReadyExceptionpublic static FHAuthRequest buildAuthRequest() throws FHNotReadyException
FHNotReadyException - if init has not been calledpublic static FHAuthRequest buildAuthRequest(String pPolicyId) throws FHNotReadyException
pPolicyId - the auth policy id used by this auth requestFHNotReadyException - if init has not been calledpublic static FHAuthRequest buildAuthRequest(String pPolicyId, String pUserName, String pPassword) throws FHNotReadyException
pPolicyId - the auth policy id used by this auth requestpUserName - the required user name for the auth requestpPassword - the required password for the auth requestFHNotReadyException - if init has not been calledpublic static FHCloudRequest buildCloudRequest(String pPath, String pMethod, cz.msebera.android.httpclient.Header[] pHeaders, JSONObject pParams) throws FHNotReadyException
pPath - the path of the cloud APIpMethod - currently supports GET, POST, PUT and DELETEpHeaders - headers need to be set, can be nullpParams - the request params, can be nullFHNotReadyException - if init has not been calledIllegalArgumentException - if pMethod is not one of GET, POST, PUT or DELETEpublic static String getCloudHost() throws FHNotReadyException
FHNotReadyException - if init has not been calledpublic static JSONObject getDefaultParams()
getDefaultParamsAsHeaders method to add them as HTTP request
headers.IllegalStateException - if the app property file is not loadedpublic static cz.msebera.android.httpclient.Header[] getDefaultParamsAsHeaders(cz.msebera.android.httpclient.Header[] pHeaders)
getDefaultParams, but returns HTTP headers instead.pHeaders - existing headersIllegalStateException - if the app property file is not loadedpublic static void cloud(String pPath, String pMethod, cz.msebera.android.httpclient.Header[] pHeaders, JSONObject pParams, FHActCallback pCallback) throws FHNotReadyException
pPath - the path to the cloud APIpMethod - currently supports GET, POST, PUT and DELETEpHeaders - headers need to be set, can be nullpParams - the request params, can be null. Will be converted to query strings depending
on the HTTP methodpCallback - the callback to be executed when the cloud call is finishedFHNotReadyException - if init has not been calledIllegalArgumentException - if pMethod is not one of GET, POST, PUT and DELETEpublic static void setLogLevel(int pLogLevel)
LOG_LEVEL_ERROR. Please make sure this is set to LOG_LEVEL_ERROR
or LOG_LEVEL_NONE before releasing the application.
The log level can be one of
pLogLevel - The level of logging for the FH librarypublic static int getLogLevel()
public static String getUserAgent()
public static void pushRegister(FHActCallback pCallback)
init(android.content.Context, FHActCallback) success
callback.pCallback - the pCallback function to be executed after the device registration is finishedpublic static void pushRegister(PushConfig pPushConfig, FHActCallback pCallback)
init(android.content.Context, FHActCallback) success
callback.pPushConfig - extra configuration for pushpCallback - the pCallback function to be executed after the device registration is finishedpublic static void sendPushMetrics(String pMessageId, FHActCallback pCallback)
pMessageId - Id of the message receivedpCallback - the pCallback function to be executed after the metrics sentCopyright © 2016 Red Hat. All rights reserved.