초기화하기

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

import com.wepin.android.loginlib.WepinLogin;

WepinLogin 인스턴스를 생성하기전에 아래와 같이 앱의 Activity Context , 앱ID, 앱 키를 WepinLoginOptions 객체에 전달해 주세요.

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

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

WepinLogin wepinLogin = new WepinLogin(wepinLoginOptions);

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

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

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

반환값은 아래와 같습니다.

  • boolean init 결괏값, init이 정상적으로 잘 된 경우 true 실패한 경우 false 를 반환합니다.

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

Last updated