Last Updated on : 2024-06-18 01:40:38download
A user can share a device in a home with other users in the same home so that the other users can control the device. The users who receive a sharing invitation can control the device by using their app account.
Each device can be simultaneously shared with up to 20 users.
Class name | Description |
---|---|
IThingHomeDeviceShare | Provides the capabilities to share devices. |
Shares multiple devices to a specific user and overwrites earlier sharing with the user. Each device can be simultaneously shared with up to 20 users.
API description
void addShare(long homeId, String countryCode, final String userAccount, ShareIdBean bean, boolean autoSharing, final IThingResultCallback<SharedUserInfoBean> callback);
Parameters
Parameter | Description |
---|---|
homeId | The ID of the home to which the devices belong. |
countryCode | The country code. For example, 86 means mainland China. |
userAccount | The account of the user who receives a sharing invitation. |
bean | The list of device IDs for sharing. |
autoSharing | Specifies whether automatic sharing is enabled. |
callback | The success or failure callback. null cannot be returned. |
The following table describes the data structure of ShareIdBean
.
Parameter | Type | Description |
---|---|---|
devIds | List<String> | The list of device IDs for sharing. |
meshIds | List<String> | The list of mesh device IDs for sharing. |
Example
ThingHomeSdk.getDeviceShareInstance().addShare(homeId, countryCode, userAccount,
shareIdBean, autoSharing, new IThingResultCallback<SharedUserInfoBean>() {
@Override
public void onSuccess(SharedUserInfoBean sharedUserInfoBean) {}
@Override
public void onError(String errorCode, String errorMsg) {}
});
Shares multiple devices to a specific user and adds these devices following earlier sharing with the user. If devices have ever been shared with a specified user, the subsequent sharing query API methods can be called to get the target user ID. Then, pass this user ID in the current method to implement quick sharing with the user. Each device can be simultaneously shared with up to 20 users.
API description
void addShareWithMemberId(long memberId,List<String> devIds,IResultCallback callback);
Parameters
Parameter | Description |
---|---|
memberId | The ID of the user who receives the sharing invitation. |
devIds | The list of device IDs for sharing. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().addShareWithMemberId(userId, devIdList, new IResultCallback() {
@Override
public void onError(String errorCode, String errorMsg) {
}
@Override
public void onSuccess() {
}
});
Shares one or more devices to a specific user and adds these devices following earlier sharing with the user. Each device can be simultaneously shared with up to 20 users.
API description
void addShareWithHomeId(long homeId, String countryCode, String userAccount, List<String> devIds, IThingResultCallback<SharedUserInfoBean> callback);
Parameters
Parameter | Description |
---|---|
homeId | The ID of the home to which the device belongs. |
countryCode | The country code. For example, 86 means mainland China. |
userAccount | The account of the target user who receives the sharing invitation. |
devIds | The list of device IDs for sharing. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().addShareWithHomeId(homeId, countryCode,
userAccount, devsIdList, new IThingResultCallback<SharedUserInfoBean>() {
@Override
public void onSuccess(SharedUserInfoBean sharedUserInfoBean) {
}
@Override
public void onError(String errorCode, String errorMsg) {
}
});
API description
void queryUserShareList(long homeId, final IThingResultCallback<List<SharedUserInfoBean>> callback);
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().queryUserShareList(homeId, new IThingResultCallback<List<SharedUserInfoBean>>() {
@Override
public void onSuccess(List<SharedUserInfoBean> sharedUserInfoBeans) {}
@Override
public void onError(String errorCode, String errorMsg) {}
});
API description
void queryShareReceivedUserList(final IThingResultCallback<List<SharedUserInfoBean>> callback);
Parameters
Parameter | Description |
---|---|
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().queryShareReceivedUserList(new IThingResultCallback<List<SharedUserInfoBean>>() {
@Override
public void onSuccess(List<SharedUserInfoBean> sharedUserInfoBeans) {
}
@Override
public void onError(String errorCode, String errorMsg) {
}
});
API description
void getUserShareInfo(long memberId, final IThingResultCallback<ShareSentUserDetailBean> callback);
Parameters
Parameter | Description |
---|---|
memberId | The user ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().getUserShareInfo(mRelationId, new IThingResultCallback<ShareSentUserDetailBean>() {
@Override
public void onSuccess(ShareSentUserDetailBean shareSentUserDetailBean) {}
@Override
public void onError(String errorCode, String errorMsg) {}
});
API description
void getReceivedShareInfo(long memberId, final IThingResultCallback<ShareReceivedUserDetailBean> callback);
Parameters
Parameter | Description |
---|---|
memberId | The user ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().getReceivedShareInfo(mRelationId, new IThingResultCallback<ShareReceivedUserDetailBean>() {
@Override
public void onSuccess(ShareReceivedUserDetailBean shareReceivedUserDetailBean) {}
@Override
public void onError(String errorCode, String errorMsg) {}
});
API description
void queryDevShareUserList(String devId, final IThingResultCallback<List<SharedUserInfoBean>> callback);
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().queryDevShareUserList(mDevId, new IThingResultCallback<List<SharedUserInfoBean>>() {
@Override
public void onError(String errorCode, String errorMsg) {}
@Override
public void onSuccess(List<SharedUserInfoBean> shareUserBeen) {}
});
API description
void queryShareDevFromInfo(String devId, final IThingResultCallback<SharedUserInfoBean> callback);
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().queryShareDevFromInfo(devId, new IThingResultCallback<SharedUserInfoBean>() {
@Override
public void onSuccess(SharedUserInfoBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
Removes all users who receive sharing invitations from a user denoted by memberId
who initiates sharing invitations.
API description
void removeUserShare(long memberId, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
memberId | The user ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().removeUserShare(memberId, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
})
Removes all users who initiate sharing invitations from a user denoted by memberId
who receives sharing invitations.
API description
void removeReceivedUserShare(long memberId, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
memberId | The ID of the user who receives the sharing invitations. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().removeReceivedUserShare(memberId, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
})
API description
void disableDevShare(String devId, long memberId, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
memberId | The user ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().disableDevShare (devId, memberId, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
});
API description
void removeReceivedDevShare(String devId, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().removeReceivedDevShare(devId,new IResultCallback() {
@Override
public void onError(String code, String error) {}
@Override
public void onSuccess() {}
})
API description
void renameShareNickname(long memberId, String name, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
memberId | The user ID. |
name | The new remarks of the user who initiates the sharing invitations. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().renameShareNickname(mRelationId, inputText, new IResultCallback() {
@Override
public void onError(String s, String s1) {}
@Override
public void onSuccess() {}
});
API description
void renameReceivedShareNickname(long memberId, String name, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
memberId | The home ID. You can call SharedUserInfoBean to get the value. |
name | The new remarks of the user who initiates the sharing invitations. |
callback | The success or failure callback. null cannot be returned. |
Example
ThingHomeSdk.getDeviceShareInstance().renameReceivedShareNickname(mRelationId, inputText, new IResultCallback() {
@Override
public void onError(String s, String s1) {}
@Override
public void onSuccess() {}
});
API description
void inviteShare(String devId, String userAccount, String countryCode, IThingResultCallback<Integer> callback);
Parameters
Parameter | Description |
---|---|
countryCode | The country code. |
userAccount | The target user account. |
devId | The device ID. |
success | The success callback. |
failure | The failure callback. |
Example
ThingHomeSdk.getDeviceShareInstance().inviteShare(devId, userAccount, countryCode, new IThingResultCallback<Integer>() {
@Override
public void onSuccess(Integer result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
void confirmShareInviteShare(int shareId, final IResultCallback callback);
Parameters
Parameter | Description |
---|---|
shareId | The ID of the sharing invitation. It is the integer value returned on success by the method inviteShare . |
success | The success callback. |
failure | The failure callback. |
Example
ThingHomeSdk.getDeviceShareInstance().confirmShareInviteShare(shareId, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
});
Note: The group ID appears on the device panel.
API description
void queryGroupSharedUserList(long groupId, IThingResultCallback<List<SharedUserInfoBean>> callback);
Parameters
Parameter | Description |
---|---|
groupId | The group ID. |
success | The success callback. |
failure | The failure callback. |
Example
ThingHomeSdk.getDeviceShareInstance().queryGroupSharedUserList(mGroupId, new IThingResultCallback<List<SharedUserInfoBean>>() {
@Override
public void onSuccess(List<SharedUserInfoBean> result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
void addShareUserForGroup(long homeId, String countryCode, String userAccount, long groupId, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
countryCode | The country code. |
userAccount | The target user account. |
groupId | The group ID. |
success | The success callback. |
failure | The failure callback. |
Example
ThingHomeSdk.getDeviceShareInstance().addShareUserForGroup(homeId, countryCode, userAccount, groupId, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
});
API description
void removeGroupShare(long groupId, long memberId, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
memberId | The member ID. |
groupId | The group ID. |
success | The success callback. |
failure | The failure callback. |
Example
ThingHomeSdk.getDeviceShareInstance().removeGroupShare(groupId, memberId, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback