# 初始化配置,登录

### 运行流程图

![](/files/-MERO4rZEX__vr9_cxA-)

### 初始化

```java
@Override
public void init(Context context) {
    //初始化代码块
}
```

### 获取服务配置信息

```java
@Override
public SdkInfoConfig getSdkConfig() {
    KLog.e("获取配置 getSdkConfig");
    return config;
}
```

```java
public class SdkInfoConfig {
    private boolean supportLogin;  //是否支持登录
    private String manufacturerName;  //厂商的名称
}
```

### 支持登录

需要将SdkInfoConfig对象的supportLogin配置为true,智能主机获得配置信息后判断如果为需要登录将会进入登录界面,否则直接进入搜索设备界面

当设备已经登录过后,重新开机上电,将会静默登录服务

```java
@Override
public void login(String user, String pwd) {
   JSONObject result = new JSONObject();
        if("admin".equals(user) && "123456".equals(pwd)){
            result.put("isSuccess",true);
            result.put("info","登录成功");
        }else{
            result.put("isSuccess",false);
            result.put("info","登录失败");
        }
   notifyHost(SdkAction.SDK_LOGIN,result.toJSONString()); 
}
```

登录成功后调用notifyHost方法通知智能主机登录成功\
action为[SDK\_LOGIN](/dev-link-host/android-link-sdk/action-shi-jian.md#sdk_login)

返回数据格式

```java
{
    "isSuccess":true/false
    "info":"失败或成功信息"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.youzhuan.net/dev-link-host/android-link-sdk/kai-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
