English
English
简体中文
Contact Us
Register
Log In

All Category Control Panel

Last Updated on : 2021-07-21 04:01:18download

The native control panel supports most Tuya Smart products and functions. You can quickly integrate product capabilities powered by Tuya into devices with simple access and let users easily experience different smart devices.

Advantages

  • It supports new products in advance, and provides services when a single category cannot be supported, without submitting a new app version.

  • It is native and easy to use.

  • It is easy to debug in the development phase.

  • Some panels supports supports configuration display through DIY style UI template usage guide.

    All Category Control Panel All Category Control Panel

Instructions

dependencies

implementation 'com.tuya.smart:TuyaDefaultPanel:2.1.0'

Interface description

void openDefaultPanel(Context context, String devId, MenuBean menuBean);

Parameter description

Parameters Description
context Context for opening the Activity
devId Device Id
menuBean Used to create and display custom menus and events

Note: menuBean is used to create and display custom menus and events, you can set it null if you don’t need it.

MenuBean data model

Filed Type Description
menuRes Int Custom menu resource id
menuItemId Int Item id in custom menu
bundle Bundle Custom bundle can be obtained in custom Activity by IDefaultPanelController.BUNDLE_KEY
activityClassName String Custom activity ClassName,like TestActivity.class.getName()

Sample code

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);

The native control panel uses startActivityForResult(Intent, IDefaultPanelController.REQUEST_CODE_DEFAULT_PANEL) to enable the custom activity. If the onActivityResult shows that the (requestCode == IDefaultPanelController.REQUEST_CODE_DEFAULT_PANEL && resultCode == RESULT_OK) is true, the default panel will be closed.