Java 类com.facebook.CallbackManager 实例源码

项目:FirebaseUI-Android    文件:FacebookProvider.java   
@Override
public void startLogin(Activity activity) {
    sCallbackManager = CallbackManager.Factory.create();
    LoginManager loginManager = LoginManager.getInstance();
    loginManager.registerCallback(sCallbackManager, this);

    List<String> permissionsList = new ArrayList<>(mScopes);

    // Ensure we have email and public_profile scopes
    if (!permissionsList.contains(EMAIL)) {
        permissionsList.add(EMAIL);
    }

    if (!permissionsList.contains(PUBLIC_PROFILE)) {
        permissionsList.add(PUBLIC_PROFILE);
    }

    // Log in with permissions
    loginManager.logInWithReadPermissions(activity, permissionsList);
}
项目:kognitivo    文件:ShareInternalUtility.java   
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
项目:kognitivo    文件:LoginManager.java   
/**
 * Registers a login callback to the given callback manager.
 * @param callbackManager The callback manager that will encapsulate the callback.
 * @param callback The login callback that will be called on login completion.
 */
public void registerCallback(
        final CallbackManager callbackManager,
        final FacebookCallback<LoginResult> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }
    ((CallbackManagerImpl) callbackManager).registerCallback(
            CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return LoginManager.this.onActivityResult(
                            resultCode,
                            data,
                            callback);
                }
            }
    );
}
项目:social-login-helper    文件:FacebookHelper.java   
public FacebookHelper(@NonNull FacebookListener facebookListener) {
  mListener = facebookListener;
  mCallBackManager = CallbackManager.Factory.create();
  FacebookCallback<LoginResult> mCallBack = new FacebookCallback<LoginResult>() {
    @Override public void onSuccess(LoginResult loginResult) {
      mListener.onFbSignInSuccess(loginResult.getAccessToken().getToken(),
          loginResult.getAccessToken().getUserId());
    }

    @Override public void onCancel() {
      mListener.onFbSignInFail("User cancelled operation");
    }

    @Override public void onError(FacebookException e) {
      mListener.onFbSignInFail(e.getMessage());
    }
  };
  LoginManager.getInstance().registerCallback(mCallBackManager, mCallBack);
}
项目:android-paypal-example    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ButterKnife.bind(this);

    // [START initialize_auth]
    // Initialize Firebase Auth
    mAuth = FirebaseAuth.getInstance();
    // [END initialize_auth]

    //initialize facebook callback
    callbackManager = CallbackManager.Factory.create();

}
项目:Stalker    文件:AuthenticateFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!FacebookSdk.isInitialized()) {
        FacebookSdk.sdkInitialize(getApplicationContext());
        AppEventsLogger.activateApp(getActivity().getApplication());
    }
    // Initialize Firebase Auth
    fireBaseAuth = FirebaseAuth.getInstance();
    fireBaseAuth.signOut();

    facebookCallbackManager = CallbackManager.Factory.create();
    registerFirebase();
    registerFacebookCallback();
    LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile"));
}
项目:firebase-chat-android-architecture-components    文件:ProfileActivity.java   
private void setupFacebookLogin() {
    mFacebookCallbackManager = CallbackManager.Factory.create();

    binding.facebookButton.setReadPermissions("email","public_profile");

    // Callback registration
    binding.facebookButton.registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            firebaseAuthWithFacebook(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Toast.makeText(ProfileActivity.this, "Facebook Authentication cancelled.", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(FacebookException exception) {
            Toast.makeText(ProfileActivity.this, "Facebook Authentication failed.", Toast.LENGTH_SHORT).show();
            Timber.e(exception);
        }
    });
}
项目:enklave    文件:LoginFacebook.java   
public LoginFacebook(LoginButton login, Activity context, PreferencesShared pref, final Intent intent) {
    callbackManager = CallbackManager.Factory.create();
    this.context = context;
    preferencesShared = pref;
    login.setReadPermissions(Arrays.asList("public_profile", "user_friends"));
    login.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            //Log.d("facebook", "succes" + loginResult.getAccessToken().getToken() + "id" + loginResult.getAccessToken().getExpires() + "data" + loginResult.getAccessToken().getUserId());
            conectedwithFacebook(loginResult.getAccessToken().getToken(),intent);
        }

        @Override
        public void onCancel() {
            Log.d("intra","facebook");
        }

        @Override
        public void onError(FacebookException error) {
            Log.d("facebook", "error" + error.toString());
        }

    });
}
项目:lecrec-android    文件:ActivityLaunchScreen.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();

    if(AppController.USER_ID != null && AppController.USER_TOKEN != null) {
        new CountDownTimer(1000, 100) {
            public void onTick(long millisUntilFinished) { }
            public void onFinish() {
                goActivityMain();
            }
        }.start();
    } else {
        changeToLoginView();
    }

    pref = getSharedPreferences(CONST.PREF_NAME, MODE_PRIVATE);
    editor = pref.edit();
}
项目:CustomAndroidOneSheeld    文件:FacebookShield.java   
private void initFBSdk() {
    if (!FacebookSdk.isInitialized()) {
        FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id"));
        FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    }
    callbackManager = CallbackManager.Factory.create();

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            if (eventHandler != null) {
                if (currentProfile != null)
                    eventHandler.onFacebookLoggedIn();
            }
        }
    };
}
项目:BizareChat    文件:RegistrationPresenterImpl.java   
@Override
public void setCallbackToLoginFacebookButton() {

    callbackManager = CallbackManager.Factory.create();

    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Bundle param = new Bundle();
            param.putString("fields", "id, email");
            facebookLink(loginResult);
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {
            Logger.logExceptionToFabric(error);
        }
    });
}
项目:social-journal    文件:LoginActivity.java   
void initializeFacebookLogin() {
    // Initialize Facebook Login button
    mCallbackManager = CallbackManager.Factory.create();
    LoginButton loginButton = (LoginButton) findViewById(R.id.button_facebook_login);
    loginButton.setReadPermissions("email", "public_profile", "user_posts", "user_photos");
    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.d(TAG, "facebook:onSuccess:" + loginResult);
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Log.d(TAG, "facebook:onCancel");
            // ...
        }

        @Override
        public void onError(FacebookException error) {
            Log.w(TAG, "facebook:onError", error);
        }
    });
}
项目:uPods-android    文件:ActivityMain.java   
private void init() {
    UpodsApplication.initAllResources();
    vOverlay = findViewById(R.id.vOverlay);

    //Toolbar
    toolbar.inflateMenu(R.menu.menu_activity_main);
    toolbar.setOnMenuItemClickListener(this);
    toolbar.setTitleTextColor(getResources().getColor(R.color.white));

    //Social
    callbackManager = CallbackManager.Factory.create();

    MenuItem searchMenuItem = toolbar.getMenu().findItem(R.id.action_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    UIHelper.setSearchViewStyle(searchView);
    UIHelper.changeSearchViewTextColor(searchView, Color.WHITE);

    slidingMenu = new SlidingMenu(this, toolbar);
}
项目:android-rss-feed-reader    文件:SignInPresenter.java   
@Override
public void onFacebookLoginBntClick(LoginButton loginButton) {
        mCallbackManager = CallbackManager.Factory.create();
        loginButton.setReadPermissions("email", "public_profile");
        loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                handleFacebookAccessToken(loginResult.getAccessToken());
            }

            @Override
            public void onCancel() {
            }

            @Override
            public void onError(FacebookException error) {
                getView().showSnackBar(error.getMessage());
            }
        });
}
项目:sabbath-school-android    文件:SSLoginViewModel.java   
private void configureFacebookLogin(){
    FacebookSdk.sdkInitialize(context.getApplicationContext());
    ssFacebookCallbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(ssFacebookCallbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    handleFacebookAccessToken(loginResult.getAccessToken());
                }

                @Override
                public void onCancel() {
                    // TODO: Handle unsuccessful / cancel
                }

                @Override
                public void onError(FacebookException exception) {
                    loginFailed(exception.getMessage());
                }
            });
}
项目:HaiNaBaiChuan    文件:LoginFragment.java   
private void initFaceBookLogin() {
    callbackManager = CallbackManager.Factory.create();
    btnLoginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            showDialog();
            presenter.requestFacebook(loginResult);
            LogUtil.e2(loginResult.getAccessToken().toString());
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });
}
项目:PlatePicks-Android    文件:LoginFragment.java   
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());

    callbackManager = CallbackManager.Factory.create();

    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {

        }
    };

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            //Toast.makeText(getActivity(), "newProfile", Toast.LENGTH_SHORT).show();
            //displayMessage(currentProfile);

        }
    };

    accessTokenTracker.startTracking();
    profileTracker.startTracking();
}
项目:spree-android    文件:ProfileFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments()!=null) {
        isTabBarShown = getArguments().getBoolean(SHOW_TAB_BAR);
    }
    BusProvider.getInstance().register(this);
    home = (Home) getActivity();
    user = new User();
    // manages the callbacks into the FacebookSdk from an Activity's or Fragment's onActivityResult() method
    callbackManager = CallbackManager.Factory.create();
    gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestProfile()
            .requestEmail()
            .build();

    if (googleApiClient==null) {
        googleApiClient = new GoogleApiClient.Builder(home)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();
    }

}
项目:vdb-android    文件:BaseActivity.java   
private void setFacebookRule() {
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    EventBus.getDefault().post(MessageEvent.UPDATE_FACEBOOK_PROFILE);
                }

                @Override
                public void onCancel() {
                    Log.d("Teste", "deu errp");
                }

                @Override
                public void onError(FacebookException exception) {
                    Log.d("ErrorF", exception.toString());
                }
            }
    );

    Profile profile = Profile.getCurrentProfile();

    if (profile != null) {
        this.sidebar.showHideLogoff(true);
    } else {
        this.sidebar.showHideLogoff(false);
    }

}
项目:Stalker    文件:AuthenticateFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!FacebookSdk.isInitialized()) {
        FacebookSdk.sdkInitialize(getApplicationContext());
        AppEventsLogger.activateApp(getActivity().getApplication());
    }
    // Initialize Firebase Auth
    fireBaseAuth = FirebaseAuth.getInstance();
    fireBaseAuth.signOut();

    facebookCallbackManager = CallbackManager.Factory.create();
    registerFirebase();
    registerFacebookCallback();
    LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile"));
}
项目:android-oss    文件:LoginToutViewModel.java   
private void registerFacebookCallback() {
  final PublishSubject<String> fbAccessToken = this.facebookAccessToken;
  final BehaviorSubject<FacebookException> fbAuthError = this.facebookAuthorizationError;

  this.callbackManager = CallbackManager.Factory.create();

  LoginManager.getInstance().registerCallback(this.callbackManager, new FacebookCallback<LoginResult>() {
    @Override
    public void onSuccess(final @NonNull LoginResult result) {
      fbAccessToken.onNext(result.getAccessToken().getToken());
    }

    @Override
    public void onCancel() {
      // continue
    }

    @Override
    public void onError(final @NonNull FacebookException error) {
      if (error instanceof FacebookAuthorizationException) {
        fbAuthError.onNext(error);
      }
    }
  });
}
项目:FindMeAHome    文件:ListActivity.java   
private void shareOnFacebook() {

        facebookCallbackManager = CallbackManager.Factory.create();
        ShareDialog shareDialog = new ShareDialog(this);

        if (ShareDialog.canShow(ShareLinkContent.class)) {
            ShareLinkContent linkContent = new ShareLinkContent.Builder()
                    .setShareHashtag(new ShareHashtag.Builder()
                                    .setHashtag(getString(R.string.nomorehomelessanimals)).build())
                    .setQuote(getString(R.string.explore_adoption))
                    .setContentUrl(Uri.parse(getString(R.string.findmeahome_store_url)))
                    .build();

            shareDialog.show(linkContent);
        }
    }
项目:aptoide-client-v8    文件:AccountNavigator.java   
public AccountNavigator(FragmentNavigator fragmentNavigator, AptoideAccountManager accountManager,
    ActivityNavigator activityNavigator, LoginManager facebookLoginManager,
    CallbackManager callbackManager, GoogleApiClient client,
    PublishRelay<FacebookLoginResult> facebookLoginSubject, String defaultStore,
    String defaultTheme, String recoverPasswordUrl) {
  this.fragmentNavigator = fragmentNavigator;
  this.accountManager = accountManager;
  this.activityNavigator = activityNavigator;
  this.facebookLoginManager = facebookLoginManager;
  this.callbackManager = callbackManager;
  this.client = client;
  this.facebookLoginSubject = facebookLoginSubject;
  this.defaultStore = defaultStore;
  this.defaultTheme = defaultTheme;
  this.recoverPasswordUrl = recoverPasswordUrl;
}
项目:openshop.io-android    文件:LoginDialogFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Timber.d("%s - OnCreateView", this.getClass().getSimpleName());
    View view = inflater.inflate(R.layout.dialog_login, container, false);
    callbackManager = CallbackManager.Factory.create();

    loginBaseForm = (LinearLayout) view.findViewById(R.id.login_base_form);
    loginRegistrationForm = (LinearLayout) view.findViewById(R.id.login_registration_form);
    loginEmailForm = (LinearLayout) view.findViewById(R.id.login_email_form);
    loginEmailForgottenForm = (LinearLayout) view.findViewById(R.id.login_email_forgotten_form);

    prepareLoginFormNavigation(view);
    prepareInputBoxes(view);
    prepareActionButtons(view);
    return view;
}
项目:zum-android    文件:SignUpActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.signup_activity);
    ButterKnife.bind(this);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mCallbackManager = CallbackManager.Factory.create();

    mUserService = OAuth2ServiceFactory.createAnonymousService(UserService.class);
    mValidator = new Validator(this);
    mValidator.setValidationListener(this);

    UniqueEmailRule uniqueEmailRule = new UniqueEmailRule(mName, mUserService);
    mValidator.put(mEmail, uniqueEmailRule);

    registerCallback();
}
项目:PagesManager    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    mCallbackManager = CallbackManager.Factory.create();
    setContentView(R.layout.activity_main);
    initViews();


    if (AccessToken.getCurrentAccessToken() == null) {
        //user not logged in
        hideViewsAfterLogout();
    } else {
        //user logged in
        getAvailablePagesAsync();

    }
}
项目:FastFoodFinder    文件:LoginActivity.java   
private CallbackManager setupFacebookSignIn() {
    CallbackManager callbackManager = CallbackManager.Factory.create();
    fbSignInButton.setReadPermissions("email", "public_profile");

    fbSignInButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.d("MAPP", "facebook:onSuccess: " + loginResult);
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Log.d("MAPP", "facebook:onCancel");
            // ...
        }

        @Override
        public void onError(FacebookException error) {
            Log.d("MAPP", "facebook:onError", error);
            // ...
        }
    });

    return callbackManager;
}
项目:FirebaseAuthExample    文件:LoginActivity.java   
@Override
public void initFbLoginButton() {
    mCallbackManager = CallbackManager.Factory.create();
    mLoginFbButton.setReadPermissions("email", "public_profile");
    mLoginFbButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Timber.d("facebook:onSuccess:" + loginResult);
            mPresenter.handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Timber.d("facebook:onCancel");
        }

        @Override
        public void onError(FacebookException error) {
            Timber.d("facebook:onError", error);
        }
    });
}
项目:Rocket.Chat-android    文件:LoginActivity.java   
private void setupFacebookLogin() {
    //TODO: Check if facebook login is actvated in the server
    String appId = FacebookSdk.getApplicationId();
    Timber.d("appId: " + appId);
    if (appId != null) {
        mCallbackManager = CallbackManager.Factory.create();
        mFacebookButton.setReadPermissions(PERMISSIONS);
        mFacebookButton.registerCallback(mCallbackManager, mFacebookCallback);
        mAccessTokenTracker = new AccessTokenTracker() {
            @Override
            protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
                if (currentAccessToken != null) {
                    mRxRocketMethods.loginWithFacebook(currentAccessToken.getToken(), currentAccessToken.getExpires().getTime() - new Date().getTime())
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .subscribe(mLoginSubscriber);

                }
            }
        };

    } else {
        mFacebookButton.setVisibility(View.GONE);
    }

}
项目:bachamada    文件:FacebookShare.java   
private void initFB() {
    FacebookSdk.sdkInitialize(mContext);
    callbackManager = CallbackManager.Factory.create();
    mShareDialog = new ShareDialog(mContext);
    // this part is optional
    mShareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });
}
项目:1Sheeld-Android-App    文件:FacebookShield.java   
private void initFBSdk() {
    if (!FacebookSdk.isInitialized()) {
        FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id"));
        FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    }
    callbackManager = CallbackManager.Factory.create();

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            if (eventHandler != null) {
                if (currentProfile != null)
                    eventHandler.onFacebookLoggedIn();
            }
        }
    };
}
项目:batatas-android    文件:MainFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            final Profile profile = currentProfile;
            if (profile != null) {
                final Thread thread = new Thread() {
                    public void run() {
                        createUserFromFacebook(profile);
                        openListsOverview();
                    }
                };
                thread.start();
            }
        }
    };

    printKeyHash(getActivity());
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
项目:Move-Alarm_ORCA    文件:LoginManager.java   
/**
 * Registers a login callback to the given callback manager.
 * @param callbackManager The callback manager that will encapsulate the callback.
 * @param callback The login callback that will be called on login completion.
 */
public void registerCallback(
        final CallbackManager callbackManager,
        final FacebookCallback<LoginResult> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }
    ((CallbackManagerImpl) callbackManager).registerCallback(
            CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return LoginManager.this.onActivityResult(
                            resultCode,
                            data,
                            callback);
                }
            }
    );
}
项目:EasyFacebook    文件:BaseRecyclerFragment.java   
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Logger.d("onSuccess");
            onFaceBookLoginSuccess(loginResult);
        }

        @Override
        public void onCancel() {
            Logger.d("onCancel");
            onFaceBookLoginCancel();
        }

        @Override
        public void onError(FacebookException error) {
            Logger.d("onError");
            onFaceBookLoginError(error);
        }
    });
}
项目:EasyFacebook    文件:BaseFragment.java   
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Logger.d("onSuccess");
            onFaceBookLoginSuccess(loginResult);
        }

        @Override
        public void onCancel() {
            Logger.d("onCancel");
            onFaceBookLoginCancel();
        }

        @Override
        public void onError(FacebookException error) {
            Logger.d("onError");
            onFaceBookLoginError(error);
        }
    });
}
项目:EasyFacebook    文件:BaseLoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this.getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);
    shareDialog.registerCallback(
            callbackManager,
            shareCallback);

    // Can we present the share dialog for regular links?
    canPresentShareDialog = ShareDialog.canShow(
            ShareLinkContent.class);

    // Can we present the share dialog for photos?
    canPresentShareDialogWithPhotos = ShareDialog.canShow(
            SharePhotoContent.class);
}
项目:synergykit-sdk-android    文件:SignInActivity.java   
private void registerFacebookCallback(){
    callbackManager = CallbackManager.Factory.create();
    // Callback registration
   facebookButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
       @Override
       public void onSuccess(LoginResult loginResult) {

           signInViaFacebook(loginResult.getAccessToken());

       }

       @Override
       public void onCancel() {
           // App code
       }

       @Override
       public void onError(FacebookException exception) {
           // App code
       }
   });
}
项目:nfcoauth    文件:SelectDomain.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    setContentView(R.layout.select_domain);
    TextView server = (TextView) findViewById(R.id.textView_server_url);
    url = getIntent().getStringExtra("server");
    server.setText(url);
    callbackManager = CallbackManager.Factory.create();

    findViewById(R.id.button_domain_google).setOnClickListener(this);
    ((SignInButton) findViewById(R.id.button_domain_google)).setSize(SignInButton.SIZE_WIDE);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Plus.API)
            .addScope(new Scope(Scopes.PROFILE))
            .addScope(new Scope(Scopes.EMAIL))
            .build();
}
项目:Movie-Maniac-Android    文件:ViewPodUserInfo.java   
public void setUpFacebookLoginButton(Fragment hostFragment, CallbackManager callbackManager) {
    btnLoginWithFacebook.setReadPermissions(FacebookUtils.FB_PERMISSION_LIST);
    btnLoginWithFacebook.setFragment(hostFragment);
    btnLoginWithFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            processFacebookLoginResult(loginResult);
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException exception) {

        }
    });
}