本文整理匯總了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);
}
示例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));
}
});
}
示例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);
}
}
);
}
示例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);
}
示例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();
}
示例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"));
}
示例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);
}
});
}
示例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());
}
});
}
示例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();
}
示例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();
}
}
};
}
示例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);
}
});
}
示例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);
}
});
}
示例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);
}
示例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());
}
});
}
示例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());
}
});
}