當前位置: 首頁>>代碼示例>>Java>>正文


Java CallbackManager類代碼示例

本文整理匯總了Java中com.facebook.CallbackManager的典型用法代碼示例。如果您正苦於以下問題:Java CallbackManager類的具體用法?Java CallbackManager怎麽用?Java CallbackManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CallbackManager類屬於com.facebook包,在下文中一共展示了CallbackManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startLogin

import com.facebook.CallbackManager; //導入依賴的package包/類
@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);
}
 
開發者ID:firebase,項目名稱:FirebaseUI-Android,代碼行數:21,代碼來源:FacebookProvider.java

示例2: registerSharerCallback

import com.facebook.CallbackManager; //導入依賴的package包/類
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));
                }
            });
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:23,代碼來源:ShareInternalUtility.java

示例3: registerCallback

import com.facebook.CallbackManager; //導入依賴的package包/類
/**
 * 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);
                }
            }
    );
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:26,代碼來源:LoginManager.java

示例4: FacebookHelper

import com.facebook.CallbackManager; //導入依賴的package包/類
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);
}
 
開發者ID:mukeshsolanki,項目名稱:social-login-helper,代碼行數:20,代碼來源:FacebookHelper.java

示例5: onCreate

import com.facebook.CallbackManager; //導入依賴的package包/類
@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();

}
 
開發者ID:OmarAliSaid,項目名稱:android-paypal-example,代碼行數:19,代碼來源:LoginActivity.java

示例6: onCreate

import com.facebook.CallbackManager; //導入依賴的package包/類
@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"));
}
 
開發者ID:Pavou,項目名稱:Stalker,代碼行數:17,代碼來源:AuthenticateFragment.java

示例7: setupFacebookLogin

import com.facebook.CallbackManager; //導入依賴的package包/類
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);
        }
    });
}
 
開發者ID:hbmartin,項目名稱:firebase-chat-android-architecture-components,代碼行數:25,代碼來源:ProfileActivity.java

示例8: LoginFacebook

import com.facebook.CallbackManager; //導入依賴的package包/類
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());
        }

    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:25,代碼來源:LoginFacebook.java

示例9: onCreate

import com.facebook.CallbackManager; //導入依賴的package包/類
@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();
}
 
開發者ID:lecrec,項目名稱:lecrec-android,代碼行數:21,代碼來源:ActivityLaunchScreen.java

示例10: initFBSdk

import com.facebook.CallbackManager; //導入依賴的package包/類
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();
            }
        }
    };
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:18,代碼來源:FacebookShield.java

示例11: setCallbackToLoginFacebookButton

import com.facebook.CallbackManager; //導入依賴的package包/類
@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);
        }
    });
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:25,代碼來源:RegistrationPresenterImpl.java

示例12: initializeFacebookLogin

import com.facebook.CallbackManager; //導入依賴的package包/類
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);
        }
    });
}
 
開發者ID:cache117,項目名稱:social-journal,代碼行數:25,代碼來源:LoginActivity.java

示例13: init

import com.facebook.CallbackManager; //導入依賴的package包/類
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);
}
 
開發者ID:KKorvin,項目名稱:uPods-android,代碼行數:20,代碼來源:ActivityMain.java

示例14: onFacebookLoginBntClick

import com.facebook.CallbackManager; //導入依賴的package包/類
@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());
            }
        });
}
 
開發者ID:Vovchyk,項目名稱:android-rss-feed-reader,代碼行數:21,代碼來源:SignInPresenter.java

示例15: configureFacebookLogin

import com.facebook.CallbackManager; //導入依賴的package包/類
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());
                }
            });
}
 
開發者ID:Adventech,項目名稱:sabbath-school-android,代碼行數:22,代碼來源:SSLoginViewModel.java


注:本文中的com.facebook.CallbackManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。