Last Updated on : 2024-11-18 06:40:50download
This method only applies to devices that are connected to the internet.
Map<String, Object> postData = new HashMap<>();
// The URL obtained after the device QR code is scanned.
postData.put("code", url);
TuyaHomeSdk.getRequestInstance().requestWithApiNameWithoutSession("tuya.m.qrcode.parse", "4.0", postData, String.class, new ITuyaDataCallback<String>() {
@Override
public void onSuccess(String result) {
// The UUID returned in the result.
Log.i("TAG" , result);
}
@Override
public void onError(String errorCode, String errorMessage) {
Log.i("TAG" , errorCode);
}
});
TuyaQRCodeActivatorBuilder builder = new TuyaQRCodeActivatorBuilder()
.setUuid(uuid)
.setHomeId(homeId)
.setContext(mActivity)
.setTimeOut(timeout)
.setListener(new ITuyaSmartActivatorListener() {
@Override
public void onError(String errorCode, String errorMsg) {
}
@Override
public void onActiveSuccess(DeviceBean devResp) {
}
@Override
public void onStep(String step, Object data) {
}
}
));
Parameters
Parameter | Description |
---|---|
uuid | The UUID that is returned after a device QR code is scanned. |
homeId | The home ID. For more information, see Home Management. |
timeout | The timeout value of a pairing task. Default value: 100 . Unit: seconds. |
ITuyaActivator mTuyaActivator = TuyaHomeSdk.getActivatorInstance().newQRCodeDevActivator(builder);
// Starts pairing.
mTuyaActivator.start();
// Stops pairing.
mTuyaActivator.stop();
// Destroys the pairing task.
mTuyaActivator.onDestory();
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback