> For the complete documentation index, see [llms.txt](https://docs.wepin.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wepin.io/widget-integration/android-java-and-kotlin-sdk/login-library/init.md).

# 초기화하기

Wepin Android Login Library를 초기화하는 방법입니다.&#x20;

<pre class="language-kotlin"><code class="lang-kotlin"><strong>import com.wepin.android.loginlib.WepinLogin
</strong></code></pre>

WepinLogin 인스턴스를 생성하기전에 아래와 같이 앱의 Activity Context , 앱 등록 후 할당받은 App ID와 App Key를 WepinLoginOptions 객체에 전달해 주세요.

```kotlin
val wepinLoginOptions =  WepinLoginOptions(
            context = this,
            appId = "your-wepin-app-id",
            appKey = "your-wepin-app-key"
        )
```

앞서 생성한 WepinLoginOptions 를 전달하면서 WepinLogin 인스턴스를 생성해 주세요.

```kotlin
val wepinLogin = WepinLogin(wepinLoginOptions)
```

WepinLogin 인스턴스생성 후 `init` 메서드를 호출하여 초기화를 합니다.

```kotlin
wepinLogin.init()
```

### Example

{% tabs %}
{% tab title="Java" %}

```java
public class MainActivity extends ComponentActivity {
  private WepinLogin wepinLogin;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_example_main);

      String appId = "your-wepin-app-id";
      String appKey = "your-wepin-app-key";

      WepinLoginOptions wepinLoginOptions = new WepinLoginOptions(this, appId, appKey);
      wepinLogin = new WepinLogin(wepinLoginOptions, null);

      // Call initialize function
      CompletableFuture<Boolean> res = wepinLogin.init();
      res.whenComplete((infResponse, error) -> {
          if (error == null) {
              System.out.println("infResponse: " + infResponse);
          } else {
              // render error UI
          }
      });
  }
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
class MainActivity : ComponentActivity() {
    private lateinit var wepinLogin: WepinLogin
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_example_main)

        val wepinLoginOptions =  WepinLoginOptions(
            context = this,
            appId = 'your-wepin-app-id',
            appKey = 'your-wepin-app-key'
        )
        wepinLogin = WepinLogin(wepinLoginOptions)
        // Call initialize function 
        val res: CompletableFuture<Void> = wepinLogin.init()
        res.whenComplete { infResponse, error ->
            if (error == null) {
                println("infResponse: $infResponse")
            } else {
                // render error UI
            }
    }
    // ...
}
```

{% endtab %}
{% endtabs %}

## isInitialized

`isInitialized`메서드를 이용해서 WepinLogin 인스턴스가 정상적으로 초기화 되었는지 확인할 수 있습니다. &#x20;

반환값은 아래와 같습니다.&#x20;

* \<Boolean>\
  초기화가 정상적으로 잘 된 경우 **true** , 실패한 경우 **false** 를 반환합니다.

### Example

{% tabs %}
{% tab title="Java" %}

```java
if(wepinLogin.isInitialized()){
    // Success to initialize WepinLogin
}

```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
if(wepinLogin.isInitialized()){
    // Success to initialize WepinLogin
}
```

{% endtab %}
{% endtabs %}
