Contains classes of the OneHop Engine SDK.
Classes
| Class name | Class description |
| HwOneHopSdk | Function class used for registration and more. |
| CLASS info |
| public class HwOneHopSdk |
| Function class for an app to register and deregister OneHop Engine, query the version of this function, and transfer data. |
Constant Summary
| Type | Name | Description |
| String | ONEHOP_DATA_TYPE | Data type of OneHop |
| String | ONEHOP_RECEIVE_TYPE | Data type of onOneHopReceived |
| int | ONEHOP_DATA_TYPE_BUSINESS_CONTINUITY | Data type for service continuity |
| int | ONEHOP_OK | Return value upon calling success |
| int | ONEHOP_ERR | Return value upon calling failure |
| int | ONEHOP_RECEIVE_TYPE_EVENT | Tap event of onOneHopReceived |
| int | ONEHOP_RECEIVE_TYPE_DATA | Service data of onOneHopReceived |
Public Method Summary
| Return type | Method name |
| HwOneHopSdk | getInstance()getInstance() Obtains the HwOneHopSdk instance. |
| int | registerOneHop(String packageName, int datatype, Stub appCallBack) |
| int | unRegisterOneHop(String packageName, int dataType) |
| int | oneHopSend(StringpackageName, JSONObject para) |
| String | getKitVersion() |
Constants
| Constant |
| public static final string ONEHOP_DATA_TYPE |
| Data type of OneHop: onehop_data_type |
| Constant |
| public static final string ONEHOP_RECEIVE_TYPE |
| Data type of onOneHopReceivedValue: onehop_receive_type |
| Constant |
| public static final int ONEHOP_DATA_TYPE_BUSINESS_CONTINUITY |
| Data type for service continuity. Constant Value: 7 |
| Constant |
| public static final int ONEHOP_OK |
| Return value upon calling success. Constant Value: 0 |
| Constant |
| public static final int ONEHOP_ERR |
| Return value upon calling failure. Constant Value: -1 |
| Constant |
| public static final int ONEHOP_RECEIVE_TYPE_EVENT |
| Parameter field of onOneHopReceived, indicating that the phone notifies the app of the NFC tap event via OneHop. Constant Value: 1 |
| Constant |
| public static final int ONEHOP_RECEIVE_TYPE_DATA |
| Parameter field of onOneHopReceived, indicating that the service data is transferred from the device to the app via OneHop. Constant Value: 2 |
Public Methods
| Method |
public HwOneHopSdk getInstace() |
| Obtains the HwOneHopSdk instance. |
Return
| type | description |
| HwOneHopSdk | HwOneHopSdk instance |
| Method |
public int registerOneHop(String packageName,int dataType, IOneHopSdkCallback.Stub appCallBack) |
| Enables the app to register the OneHop service with the SDK and sets the callback. The OneHop Engine SDK uses this callback to notify the app of the tapping time and to transfer service data. |
Parameters
| Parameter name | Parameter description |
| packageName | App package name. |
| dataType | App type. For details, see the definition of the corresponding constant. |
| appCallBack | Callback registered by an app with OneHop Engine. The app obtains the current status of OneHop Engine and the event to be synced through this callback. |
Return
| type | description |
| int | Returns the registration result. ONEHOP_OK indicates success, while ONEHOP_ERR indicates failure. |
| Method |
public int unRegisterOneHop(String packageName, int datatype) |
| The app removes the OneHop service via the SDK. |
Parameters
| Parameter name | Parameter description |
| packageName | App package name. |
Return
| type | description |
| int | Returns the result. ONEHOP_OK indicates success, while ONEHOP_ERR indicates failure. |
| Method |
public int oneHopSend(String packageName, JSONObject para) |
| The app uses this API to sync data via OneHop. Through this API, the phone notifies the app of the tap event, and the app will then transfer the corresponding service data to OneHop Engine. Call this API when the app receives the tap event from OneHop Engine through the registered callback. |
Parameters
| Parameter name | Parameter description |
| packageName | App package name. |
| para | Data synchronization parameter in JSON format. |
Return
| type | Description |
| int | Returns the result. ONEHOP_OK indicates success, while ONEHOP_ERR indicates failure. |
| Method |
public void loadAd (PublisherAdRequest publisherAdRequest)public String getKitVersion() |
| The app obtains the OneHop Engine version through this API to check whether the current phone supports the OneHop-related services. |
Parameters
Return
| type | Description |
| String | Version number, such as 22.2.2.1 |