Initialization

This is how to initialize the Wepin Android Login Library.

import com.wepin.android.loginlib.WepinLogin;

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

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

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

WepinLogin wepinLogin = new WepinLogin(wepinLoginOptions);

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

wepinLogin.init()

Example

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
          }
      });
  }
}

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.

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

Last updated