Last Updated on : 2024-03-04 08:54:43
Sweeper SDK can be integrated to implement multiple capabilities. For example, download a voice package and listen for the download progress.
The Tuya IoT Development Platform currently does not support configurations of voice packages. You can ask Tuya’s account manager to help with the configurations.
API description
void getFileList(final IThingResultCallback<ArrayList<SweeperFileListInfoBean>> callback);
Data structure of SweeperFileListInfoBean
Field | Type | Description |
---|---|---|
id | long | The voice package ID. |
name | String | The name of the voice package. |
desc | String | The description of the voice package. |
auditionUrl | String | The URL for downloading the sample voice package. |
officialUrl | String | The URL for downloading the complete voice package. |
imgUrl | String | The URL of the voice package icon. |
region | List<String> | The country or region code. |
Example
IThingSweeperKitSdk iThingSweeperKitSdk = ThingOptimusSdk.getManager(IThingSweeperKitSdk.class);
IThingSweeperFileDownload iThingSweeperFileDownload = iThingSweeperKitSdk.newFileDownloadInstance(devId);
iThingSweeperFileDownload.getFileList(new IThingResultCallback<ArrayList<SweeperFileListInfoBean>>() {
@Override
public void onSuccess(ArrayList<SweeperFileListInfoBean> result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
void getFileList(int offset, int limit, IThingResultCallback<SweeperFileListPageBean> callback);
Parameters
Parameter | Description |
---|---|
offset | The offset of returned data to display data on pages. |
limit | The maximum number of entries to be returned in each call. |
callback | Trigger a data callback |
Data structure of SweeperFileListPageBean
Field | Type | Description |
---|---|---|
datas | List<SweeperFileListInfoBean> | List of SweeperFileListInfoBean |
totalCount | int | The total number of entries. |
Example
IThingSweeperKitSdk iThingSweeperKitSdk = ThingOptimusSdk.getManager(IThingSweeperKitSdk.class);
IThingSweeperFileDownload iThingSweeperFileDownload = iThingSweeperKitSdk.newFileDownloadInstance(devId);
iThingSweeperFileDownload.getFileList(0, 10, new IThingResultCallback<SweeperFileListPageBean>() {
@Override
public void onSuccess(SweeperFileListPageBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
void registerDownloadListener(final ISweeperFileDownloadListener listener)
void unRegisterDownloadListener();
Data structure of ISweeperFileDownloadListener
/**
*
* @param type The type of file. A voice package is represented by `DOWNLOAD_VOICE`.
* @param fileDownloadEnum The Enum values of the download status. For example, a file can be downloaded or failed to be downloaded.
*/
void onResultStatus(String type, SweeperFileDownloadEnum fileDownloadEnum);
/**
*
* @param type
* @param progress The download progress.
*/
void onProgress(String type, int progress);
Example
IThingSweeperKitSdk iThingSweeperKitSdk = ThingOptimusSdk.getManager(IThingSweeperKitSdk.class);
IThingSweeperFileDownload iThingSweeperFileDownload = iThingSweeperKitSdk.newFileDownloadInstance(devId);
iThingSweeperFileDownload.registerDownloadListener(new ISweeperFileDownloadListener() {
@Override
public void onResultStatus(String type, SweeperFileDownloadEnum fileDownloadEnum) {
}
@Override
public void onProgress(String type, int progress) {
}
});
iThingSweeperFileDownload.unRegisterDownloadListener();
API description
/**
*
* @param fileId The voice package ID.
* @param callback
*/
void confirmDownload(long fileId, final IThingResultCallback<Integer> callback);
Example
IThingSweeperKitSdk iThingSweeperKitSdk = ThingOptimusSdk.getManager(IThingSweeperKitSdk.class);
IThingSweeperFileDownload iThingSweeperFileDownload = iThingSweeperKitSdk.newFileDownloadInstance(devId);
iThingSweeperFileDownload.confirmDownload(1000, new IThingResultCallback<Integer>() {
@Override
public void onSuccess(Integer result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
Returns the current download progress.
void queryProgress(final IThingResultCallback<SweeperProgressbean> callback);
Data structure of SweeperProgressbean
Field | Type | Description |
---|---|---|
id | long | The voice package ID. |
rate | int | The download progress. |
status | int | The download status. Valid values:
|
Example
IThingSweeperKitSdk iThingSweeperKitSdk = ThingOptimusSdk.getManager(IThingSweeperKitSdk.class);
IThingSweeperFileDownload iThingSweeperFileDownload = iThingSweeperKitSdk.newFileDownloadInstance(devId);
iThingSweeperFileDownload.queryProgress(new IThingResultCallback<SweeperProgressbean>() {
@Override
public void onSuccess(SweeperProgressbean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
Finishes and exits the downloading process to avoid the excessive use of process resources.
API description
void onDestroy();
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback