Updated on 2022-02-24 GMT+08:00

Disconnecting a Device

API Function

This API is used to disconnect a device from the IoT platform.

API Description

1
public static boolean logout();

Class

LoginService

Parameter Description

N/A

Return Value

Return Value

Description

true

Success

false

Failure

NOTE:

Return values only show API calling results. For example, the return value true indicates that the API is called successfully but does not indicate that the logout is successful. The logout is successful only after the LoginService broadcast is received.

Example

Call this API to disconnect a device.

1
LoginService. logout();

Implement the observer API provided by the AgentLite before calling this API.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
public class AgentliteLogin implements MyObserver {
    public AgentliteLogin (Observable loginService) {
        loginService. registerObserver (this);
    }
//Override the update method in the AgentliteLogin.
    @Override
    public void update(IotaMessage arg0) {
        // TODO Auto-generated method stub
        System.out.println("LoginManager receives a notification:" + arg0)
        int mMsgType = arg0.getMsgType();
        switch(mMsgType) {
            case 1:
            loginResultAction(arg0);
            break;
            case 2:
            logoutResultAction(arg0);
            break;
            default:
            break;
        }
    }