> 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/en/widget-integration/android-java-and-kotlin-sdk/login-library/init.md).

# Initialization

This is how to initialize the Wepin Android Login Library.

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

Before creating a WepinLogin instance, please pass the app's Activity Context, App ID, and App Key to the WepinLoginOptions object as follows.

```kotlin
WepinLoginOptions wepinLoginOptions = new WepinLoginOptions(this, appId, appKey);
```

Please create the WepinLogin instance by passing the previously created WepinLoginOptions.

```kotlin
WepinLogin wepinLogin = new WepinLogin(wepinLoginOptions);
```

After creating the WepinLogin instance, call the `init` method to proceed with the initialization.

```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 = getResources().getString(R.string.wepin_app_id);
      String appKey = getResources().getString(R.string.wepin_app_key);

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

      // 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=resources.getString(R.string.wepin_app_id),
            appKey = resources.getString(R.string.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

You can use the `isInitialized` method to check whether the WepinLogin instance has been initialized correctly. The return values are as follows:

* *boolean*\
  it returns **true** if the initialization is successful and **false** if the initialization fails.

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