예제 #1
0
 private boolean checkPlayServices() {
   int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
   if (resultCode != ConnectionResult.SUCCESS) {
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
       GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST)
           .show();
     } else {
       Logger.getInstance().w("This device is not supported.");
       finish();
     }
     return false;
   }
   return true;
 }
예제 #2
0
  /**
   * GCM으로부터 푸시 토큰을 얻어 카카오 푸시 서버에 등록하고 이를 SharedPreference에 저장한다.
   *
   * @param savedInstanceState activity 내려갈 때 저장해둔 정보
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    context = getApplicationContext();

    if (checkPlayServices()) {
      gcm = GoogleCloudMessaging.getInstance(this);
      regId = PushToken.getRegistrationId();
      deviceUUID = PushToken.getDeviceUUID();

      if (regId.isEmpty()) {
        registerPushToken(null);
      }
    } else {
      Logger.getInstance().w("No valid Google Play Services APK found.");
    }
  }
예제 #3
0
  @Override
  public boolean tryAuthorize(final AuthorizationCodeRequest request) {
    OnWebViewCompleteListener listener =
        new OnWebViewCompleteListener() {
          @Override
          public void onComplete(String redirectURL, KakaoException exception) {
            onWebViewCompleted(redirectURL, exception);
          }
        };
    try {
      final Bundle parameters = new Bundle();
      parameters.putString(ServerProtocol.CLIENT_ID_KEY, request.getAppKey());
      parameters.putString(ServerProtocol.REDIRECT_URI_KEY, request.getRedirectURI());
      parameters.putString(ServerProtocol.RESPONSE_TYPE_KEY, ServerProtocol.CODE_KEY);

      final Bundle extraParams = request.getExtras();
      if (extraParams != null && !extraParams.isEmpty()) {
        for (String key : extraParams.keySet()) {
          String value = extraParams.getString(key);
          if (value != null) {
            parameters.putString(key, value);
          }
        }
      }

      final Activity currentContext = authorizer.getCallerActivity();
      synchronizeCookies(currentContext);

      Uri uri =
          Utility.buildUri(
              ServerProtocol.AUTH_AUTHORITY, ServerProtocol.AUTHORIZE_CODE_PATH, parameters);
      loginDialog = new KakaoWebViewDialog(currentContext, uri.toString(), listener);
      loginDialog.show();
    } catch (Throwable t) {
      Logger.getInstance().i("WebViewAuthHandler is failed", t);
      return false;
    }
    return true;
  }