Last Updated on : 2024-11-18 11:33:13
Native control panels for switches are developed based on native code and support all switch categories.
Dependency
implementation 'com.tuya.smart:TuyaSwitchPanelPanel:1.0.1'
API description
void openDefaultPanel(Context context, String devId, MenuBean menuBean);
Parameters
Parameter | Description |
---|---|
context | The context to start an activity. |
devId | The device ID. |
menuBean | Creates and displays custom menus and events. |
menuBean
can be set to null if it is not required.
MenuBean data model
Field | Data type | Description |
---|---|---|
menuRes | int | The ID of a custom menu resource. |
menuItemId | int | The value of itemId for the custom menu. |
bundle | Bundle | The Bundle that passes custom data. You can use IDefaultPanelController.BUNDLE_KEY to get the value from Intent . |
activityClassName | String | The value of ClassName for a custom activity. Example: TestActivity.class.getName() . |
Java example
MenuBean menuBean = new MenuBean();
menuBean.setMenuRes(R.menu.common_menu);
menuBean.setMenuItemId(R.id.check);
Bundle bundle = new Bundle();
bundle.putString("DEV_ID_KEY", devId);
menuBean.setBundle(bundle);
menuBean.setActivityClassName(TestActivity.class.getName());
IDefaultPanelController defaultPanelController = PluginManager.service(IDefaultPanelController.class);
defaultPanelController.usePanel(new HomeSDKPanel());
defaultPanelController.openDefaultPanel(context, devId, menuBean);
startActivityForResult(Intent, IDefaultPanelController.REQUEST_CODE_DEFAULT_PANEL)
to start a custom activity
.onActivityResult
, the application disables native control panels if (requestCode == IDefaultPanelController.REQUEST_CODE_DEFAULT_PANEL && resultCode == RESULT_OK)
is true
.Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback