Last Updated on : 2024-02-01 02:14:26download
Scene UI BizBundle for Android provides the service logic and UI to implement adding and editing smart scenes in the smart scene module.
Smart scenes include the following types: tap-to-run and automation.
Tuya supports users’ smart life requirements. For example, set weather conditions or device status as triggers for a specific smart scene. When any triggers occur, one or more linked devices will run predefined tasks.
Integrate Smart Life App SDK for Android into your project with Android Studio and add the framework of the UI BizBundle to your project.
You must add the Hilt dependencies before the UI BizBundle can be used. For more information, see the document Dependency injection with Hilt on Google Developers.
build.gradle
dependencies {
implementation 'com.thingclips.smart:thingsmart-bizbundle-scene:2.0.0-cube.2'
}
The UI BizBundle relies on the implementation of IThingSceneBusinessService
to provide services.
Example
// Returns the services provided by the Scene UI BizBundle.
IThingSceneBusinessService iThingSceneBusinessService = MicroContext.findServiceByInterface(IThingSceneBusinessService.class.getName());
Accesses the page for adding a scene by home ID.
API description
public abstract void addSceneBean(Activity activity, long homeId, int requestCode);
iThingSceneBusinessService.addSceneBean
to add a scene. The type of response parameter of onActivityResult
is NormalScene
.Parameters
Parameter | Type | Description |
---|---|---|
activity | Activity | The object of Activity . |
homeId | long | The home ID. For more information, see Home Information Management. |
requestCode | int | The request code. The value can be returned by onActivityResult . |
Example
if(null != iThingSceneBusinessService && homeId != 0) {
iThingSceneBusinessService.addSceneBean(activity, homeId, requestCode);
}
Accesses the page for editing a scene by scene data and home ID.
API description
Opens the page for editing a scene.
public abstract void editSceneBean(Activity activity, long homeId, NormalScene sceneBean, int requestCode);
iThingSceneBusinessService.editSceneBean
to edit a scene. The type of response parameter of onActivityResult
is NormalScene
.Parameters
Parameter | Type | Description |
---|---|---|
activity | Activity | The object of Activity . |
homeId | long | The home ID. For more information, see Home Information Management. |
sceneBean | NormalScene | The object of scene data. You can call smart scene API methods to get the required data. |
requestCode | int | The request code. The value can be returned by onActivityResult . |
Example
ThingHomeSdk.getSceneServiceInstance().baseService().getSimpleSceneAll(homeId,
new IResultCallback<List<NormalScene>>() {
@Override
public void onSuccess(List<NormalScene> normalScenes) {
if (!normalScenes.isEmpty()) {
NormalScene sceneBean = normalScenes.get(0);
if (null != iThingSceneBusinessService) {
iThingSceneBusinessService.editSceneBean(SceneActivity.this, homeId, sceneBean, requestCode);
}
}
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
Sets the geographic location before a user can use the scene conditions and validity period. Otherwise, city information cannot be automatically returned in specific searches. However, users can still select a target city from the city list.
API description
public abstract void setAppLocation(double longitude, double latitude);
Parameters
Parameter | Description |
---|---|
longitude | The longitude, provided by the third-party map service that is integrated into your app. |
latitude | The latitude, provided by the third-party map service that is integrated into your app. |
Example
if(null != iThingSceneBusinessService){
iThingSceneBusinessService.setAppLocation(lng, lat);
}
Provides the geographic location in the scene conditions. It can be ignored if accounts that are registered in locations outside mainland China are not managed. The map class must be set for accounts registered in locations outside mainland China. Otherwise, the cities in mainland China are queried by default.
API description
public abstract void setMapActivity(Class<? extends Activity> clazz);
Parameters
Parameter | Description |
---|---|
clazz | The object of the map Activity class. |
Example
if(null != iThingSceneBusinessService){
// The following example shows the built-in map package that can be available after the Maps Service UI BizBundle is integrated. You can use a third-party map for implementation as needed.
iThingSceneBusinessService.setMapActivity(com.thingclips.smart.map.generalmap.ui.GeneralMapActivity.class);
}
Sends a specified location on the map to the UI BizBundle after the map class is integrated. This helps to update the location information.
API description
public abstract void saveMapData(double longitude, double latitude, String city, String address);
Parameters
Parameter | Description |
---|---|
longitude | The longitude. |
latitude | The latitude. |
city | The city information. |
address | The address information. |
Example
if(null != iThingSceneBusinessService){
iThingSceneBusinessService.saveMapData(lng, lat, city, address);
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback