当前位置: 首页>>代码示例>>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;未经允许,请勿转载。