com.facebook.FacebookCallback Java Examples
The following examples show how to use
com.facebook.FacebookCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Login.java From UberClone with MIT License | 7 votes |
private void setupFacebookStuff() { // This should normally be on your application class FacebookSdk.sdkInitialize(getApplicationContext()); mLoginManager = LoginManager.getInstance(); mFacebookCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { //login firebaseHelper.registerByFacebookAccount(); } @Override public void onCancel() { Toast.makeText(Login.this,"The login was canceled",Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException error) { Toast.makeText(Login.this,"There was an error in the login",Toast.LENGTH_SHORT).show(); } }); }
Example #2
Source File: JoinAppGroupDialog.java From kognitivo with Apache License 2.0 | 6 votes |
@Override protected void registerCallbackImpl ( final CallbackManagerImpl callbackManager, final FacebookCallback<Result> callback) { final ResultProcessor resultProcessor = (callback == null) ? null : new ResultProcessor(callback) { @Override public void onSuccess(AppCall appCall, Bundle results) { callback.onSuccess(new Result(results)); } }; CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() { @Override public boolean onActivityResult(int resultCode, Intent data) { return ShareInternalUtility.handleActivityResult( getRequestCode(), resultCode, data, resultProcessor); } }; callbackManager.registerCallback(getRequestCode(), callbackManagerCallback); }
Example #3
Source File: LoginFragment.java From HaiNaBaiChuan with Apache License 2.0 | 6 votes |
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) { } }); }
Example #4
Source File: LoginActivity.java From social-app-android with Apache License 2.0 | 6 votes |
private void initFacebookSignIn() { mCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { LogUtil.logDebug(TAG, "facebook:onSuccess:" + loginResult); presenter.handleFacebookSignInResult(loginResult); } @Override public void onCancel() { LogUtil.logDebug(TAG, "facebook:onCancel"); } @Override public void onError(FacebookException error) { LogUtil.logError(TAG, "facebook:onError", error); showSnackBar(error.getMessage()); } }); findViewById(R.id.facebookSignInButton).setOnClickListener(v -> presenter.onFacebookSignInClick()); }
Example #5
Source File: Login.java From UberClone with MIT License | 6 votes |
private void setupFacebookStuff() { // This should normally be on your application class FacebookSdk.sdkInitialize(getApplicationContext()); mLoginManager = LoginManager.getInstance(); mFacebookCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { //login firebaseHelper.registerByFacebookAccount(); } @Override public void onCancel() { Toast.makeText(Login.this,"The login was canceled",Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException error) { Toast.makeText(Login.this,"There was an error in the login",Toast.LENGTH_SHORT).show(); } }); }
Example #6
Source File: FireSignin.java From Learning-Resources with MIT License | 6 votes |
private void signInFacebook() { mPrgrsbrMain.setVisibility(View.VISIBLE); LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "email")); LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // Facebook Sign In was successful, authenticate with Firebase firebaseAuthWithFacebook(loginResult.getAccessToken()); } @Override public void onCancel() { LogManager.printLog(LOGTYPE_DEBUG, "facebook:onCancel"); mPrgrsbrMain.setVisibility(View.GONE); } @Override public void onError(FacebookException error) { Log.d(LOG_TAG, "facebook:onError", error); mPrgrsbrMain.setVisibility(View.GONE); } }); }
Example #7
Source File: AccountNavigator.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
public void navigateToFacebookSignUpForResult(Collection<String> permissions) { facebookLoginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { facebookLoginSubject.call( new FacebookLoginResult(loginResult, FacebookLoginResult.STATE_SUCCESS, null)); } @Override public void onCancel() { facebookLoginSubject.call( new FacebookLoginResult(null, FacebookLoginResult.STATE_CANCELLED, null)); } @Override public void onError(FacebookException error) { facebookLoginSubject.call( new FacebookLoginResult(null, FacebookLoginResult.STATE_ERROR, error)); } }); facebookLoginManager.logInWithReadPermissions(activityNavigator.getActivity(), permissions); }
Example #8
Source File: FacebookAuth.java From edx-app-android with Apache License 2.0 | 6 votes |
public FacebookAuth(Activity activity) { super(activity); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { if (callback != null) { callback.onLogin(loginResult.getAccessToken().getToken()); } logger.debug("Facebook Logged in successfully."); } @Override public void onCancel() { logger.debug("Facebook Log in canceled."); } @Override public void onError(FacebookException error) { logger.error(error); } }); }
Example #9
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 6 votes |
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)); } }); }
Example #10
Source File: LoginActivity.java From social-app-android with Apache License 2.0 | 6 votes |
private void initFacebookSignIn() { mCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { LogUtil.logDebug(TAG, "facebook:onSuccess:" + loginResult); presenter.handleFacebookSignInResult(loginResult); } @Override public void onCancel() { LogUtil.logDebug(TAG, "facebook:onCancel"); } @Override public void onError(FacebookException error) { LogUtil.logError(TAG, "facebook:onError", error); showSnackBar(error.getMessage()); } }); findViewById(R.id.facebookSignInButton).setOnClickListener(v -> presenter.onFacebookSignInClick()); }
Example #11
Source File: FacebookHelper.java From social-login-helper-Deprecated- with MIT License | 6 votes |
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); }
Example #12
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 6 votes |
/** * Register call back manager. * * @param activity the activity */ private void registerCallBackManager(final Activity activity) { LoginManager.getInstance() .registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { mLoginResult = loginResult; getUserProfile(activity); } @Override public void onCancel() { mFacebookLoginResultCallBack.onFacebookLoginCancel(); } @Override public void onError(FacebookException error) { mFacebookLoginResultCallBack.onFacebookLoginError(error); } }); }
Example #13
Source File: CreateAppGroupDialog.java From kognitivo with Apache License 2.0 | 6 votes |
@Override protected void registerCallbackImpl( final CallbackManagerImpl callbackManager, final FacebookCallback<Result> callback) { final ResultProcessor resultProcessor = (callback == null) ? null : new ResultProcessor(callback) { @Override public void onSuccess(AppCall appCall, Bundle results) { callback.onSuccess(new Result(results.getString("id"))); } }; CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() { @Override public boolean onActivityResult(int resultCode, Intent data) { return ShareInternalUtility.handleActivityResult( getRequestCode(), resultCode, data, resultProcessor); } }; callbackManager.registerCallback(getRequestCode(), callbackManagerCallback); }
Example #14
Source File: LoginManager.java From kognitivo with Apache License 2.0 | 6 votes |
/** * 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); } } ); }
Example #15
Source File: ShareApi.java From kognitivo with Apache License 2.0 | 6 votes |
private void shareLinkContent(final ShareLinkContent linkContent, final FacebookCallback<Sharer.Result> callback) { final GraphRequest.Callback requestCallback = new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { final JSONObject data = response.getJSONObject(); final String postId = (data == null ? null : data.optString("id")); ShareInternalUtility.invokeCallbackWithResults(callback, postId, response); } }; final Bundle parameters = new Bundle(); this.addCommonParameters(parameters, linkContent); parameters.putString("message", this.getMessage()); parameters.putString("link", Utility.getUriString(linkContent.getContentUrl())); parameters.putString("picture", Utility.getUriString(linkContent.getImageUrl())); parameters.putString("name", linkContent.getContentTitle()); parameters.putString("description", linkContent.getContentDescription()); parameters.putString("ref", linkContent.getRef()); new GraphRequest( AccessToken.getCurrentAccessToken(), getGraphPath("feed"), parameters, HttpMethod.POST, requestCallback).executeAsync(); }
Example #16
Source File: VideoUploader.java From kognitivo with Apache License 2.0 | 6 votes |
private UploadContext( ShareVideoContent videoContent, String graphNode, FacebookCallback<Sharer.Result> callback) { // Store off the access token right away so that under no circumstances will we // end up with different tokens between phases. We will rely on the access token tracker // to cancel pending uploads. this.accessToken = AccessToken.getCurrentAccessToken(); this.videoUri = videoContent.getVideo().getLocalUrl(); this.title = videoContent.getContentTitle(); this.description = videoContent.getContentDescription(); this.ref = videoContent.getRef(); this.graphNode = graphNode; this.callback = callback; this.params = videoContent.getVideo().getParameters(); }
Example #17
Source File: VideoUploader.java From kognitivo with Apache License 2.0 | 6 votes |
public static synchronized void uploadAsync( ShareVideoContent videoContent, String graphNode, FacebookCallback<Sharer.Result> callback) throws FileNotFoundException { if (!initialized) { registerAccessTokenTracker(); initialized = true; } Validate.notNull(videoContent, "videoContent"); Validate.notNull(graphNode, "graphNode"); ShareVideo video = videoContent.getVideo(); Validate.notNull(video, "videoContent.video"); Uri videoUri = video.getLocalUrl(); Validate.notNull(videoUri, "videoContent.video.localUrl"); UploadContext uploadContext = new UploadContext(videoContent, graphNode, callback); uploadContext.initialize(); pendingUploads.add(uploadContext); enqueueUploadStart( uploadContext, 0); }
Example #18
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 6 votes |
/** * Register call back manager to Google log in button. * * @param activity the activity * @param loginButton the login button */ private void registerCallBackManager(final Activity activity, LoginButton loginButton) { loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { mLoginResult = loginResult; getUserProfile(activity); } @Override public void onCancel() { mFacebookLoginResultCallBack.onFacebookLoginCancel(); } @Override public void onError(FacebookException error) { mFacebookLoginResultCallBack.onFacebookLoginError(error); } }); }
Example #19
Source File: GameRequestDialog.java From kognitivo with Apache License 2.0 | 5 votes |
@Override protected void registerCallbackImpl( final CallbackManagerImpl callbackManager, final FacebookCallback<Result> callback) { final ResultProcessor resultProcessor = (callback == null) ? null : new ResultProcessor(callback) { @Override public void onSuccess(AppCall appCall, Bundle results) { if (results != null) { callback.onSuccess(new Result(results)); } else { onCancel(appCall); } } }; callbackManager.registerCallback( getRequestCode(), new CallbackManagerImpl.Callback() { @Override public boolean onActivityResult(int resultCode, Intent data) { return ShareInternalUtility.handleActivityResult( getRequestCode(), resultCode, data, resultProcessor); } }); }
Example #20
Source File: LoginActivity.java From android with MIT License | 5 votes |
private void setupFacebookLogin() { facebookCallbackManager = CallbackManager.Factory.create(); vFacebookButton.setReadPermissions(getResources().getString(R.string.facebook_permissions)); vFacebookButton.registerCallback(facebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { final String token = loginResult.getAccessToken().getToken(); runSocialLoginTask(Const.ApiValues.OAUTH_TYPE_FACEBOOK, token); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { try { final String message = String.format( getResources().getString(R.string.snackbar_auth_error_facebook), error.getMessage() ); RedSnackbar.make(findViewById(R.id.root_view), message, Snackbar.LENGTH_LONG) .show(); } catch (NullPointerException e) { e.printStackTrace(); } } }); vFacebookButton.setTypeface(TypefaceHelper.getTypeface(this, Const.TypeFaces.REGULAR)); }
Example #21
Source File: AbsModuleFragment.java From ONE-Unofficial with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(getLayoutId(), null); ButterKnife.bind(this, view); shareDialog = new ShareDialog(this); CallbackManager callbackManager = CallbackManager.Factory.create(); shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { } @Override public void onCancel() { } @Override public void onError(FacebookException error) { TextToast.shortShow(getString(R.string.share_fail)); } }); pager.setOnPageChangeListener(this); pager.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ViewPager>() { @Override public void onRefresh(PullToRefreshBase<ViewPager> refreshView) { refresh(); } }); adapter = new FragmentAdapter(getChildFragmentManager(), new ArrayList<AbsBaseFragment>()); pager.setAdapter(adapter); init(); instance=this; return view; }
Example #22
Source File: LoginManager.java From kognitivo with Apache License 2.0 | 5 votes |
private void finishLogin( AccessToken newToken, LoginClient.Request origRequest, FacebookException exception, boolean isCanceled, FacebookCallback<LoginResult> callback) { if (newToken != null) { AccessToken.setCurrentAccessToken(newToken); Profile.fetchProfileForCurrentAccessToken(); } if (callback != null) { LoginResult loginResult = newToken != null ? computeLoginResult(origRequest, newToken) : null; // If there are no granted permissions, the operation is treated as cancel. if (isCanceled || (loginResult != null && loginResult.getRecentlyGrantedPermissions().size() == 0)) { callback.onCancel(); } else if (exception != null) { callback.onError(exception); } else if (newToken != null) { callback.onSuccess(loginResult); } } }
Example #23
Source File: LoginActivity.java From android-paypal-example with Apache License 2.0 | 5 votes |
@OnClick(R.id.fb_login) public void setUpFacebookLoginButton() { LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile")); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { handleFacebookAccessToken(loginResult.getAccessToken()); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { if(!isNetworkConnected()){ Snackbar.make(findViewById(android.R.id.content),"please check internet connection" ,Snackbar.LENGTH_SHORT).show(); }else{ Snackbar.make(findViewById(android.R.id.content),"unexpected error,please try again later" ,Snackbar.LENGTH_SHORT).show(); } } }); }
Example #24
Source File: FacebookDialogBase.java From kognitivo with Apache License 2.0 | 5 votes |
@Override public final void registerCallback( final CallbackManager callbackManager, final FacebookCallback<RESULT> callback) { if (!(callbackManager instanceof CallbackManagerImpl)) { throw new FacebookException("Unexpected CallbackManager, " + "please use the provided Factory."); } registerCallbackImpl((CallbackManagerImpl)callbackManager, callback); }
Example #25
Source File: LoginInteractorImpl.java From Saude-no-Mapa with MIT License | 5 votes |
@Override public void requestLoginToFacebook(List<String> permissions, FacebookCallback<LoginResult> callback) { mCallbackmanager = CallbackManager.Factory.create(); LoginManager.getInstance() .logInWithReadPermissions((LoginActivity) mContext, permissions); LoginManager.getInstance() .registerCallback(mCallbackmanager, callback); }
Example #26
Source File: LoginActivity.java From Simple-Blog-App with MIT License | 5 votes |
private void fbInit() { FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d("facebook:token", AccessToken.getCurrentAccessToken().getToken()); AccessToken.getCurrentAccessToken().getToken(); signInWithFacebook(loginResult.getAccessToken()); } @Override public void onCancel() { Log.d(TAG, "facebook:onCancel"); } @Override public void onError(FacebookException error) { Log.d(TAG, "facebook:onError", error); } }); fbImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LoginManager.getInstance().logInWithReadPermissions(LoginActivity.this, Arrays.asList("email", "user_location", "user_birthday", "public_profile", "user_friends")); } }); }
Example #27
Source File: SocialSharePlugin.java From social_share_plugin with BSD 2-Clause "Simplified" License | 5 votes |
private void facebookShare(String caption, String mediaPath) { final File media = new File(mediaPath); final Uri uri = FileProvider.getUriForFile(activity, activity.getPackageName() + ".social.share.fileprovider", media); final SharePhoto photo = new SharePhoto.Builder().setImageUrl(uri).setCaption(caption).build(); final SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build(); final ShareDialog shareDialog = new ShareDialog(activity); shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { channel.invokeMethod("onSuccess", null); Log.d("SocialSharePlugin", "Sharing successfully done."); } @Override public void onCancel() { channel.invokeMethod("onCancel", null); Log.d("SocialSharePlugin", "Sharing cancelled."); } @Override public void onError(FacebookException error) { channel.invokeMethod("onError", error.getMessage()); Log.d("SocialSharePlugin", "Sharing error occurred."); } }); if (ShareDialog.canShow(SharePhotoContent.class)) { shareDialog.show(content); } }
Example #28
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 5 votes |
/** * Share content on facebook wall * * @param activity the activity * @param callback the callback to receive a result of this share * @param url the url you wish to share * @param quote the text you wish to associate with the url shared */ private void shareLinkOnFacebook(@NonNull final Activity activity, @NonNull final FacebookShareResultCallback callback, @NonNull String url, @Nullable String quote) { ShareDialog shareDialog = new ShareDialog(activity); shareDialog.registerCallback(mCallbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { callback.onFacebookShareSuccess(result); } @Override public void onCancel() { callback.onFacebookShareCancel(); } @Override public void onError(FacebookException error) { callback.onFacebookShareError(error); } }, RC_FACEBOOK_SHARE); if (ShareDialog.canShow(ShareLinkContent.class)) { ShareLinkContent linkContent = new ShareLinkContent.Builder().setContentUrl(Uri.parse(url)) .setQuote(quote) .build(); shareDialog.show(linkContent); } else { callback.onFacebookShareCannotShowDialog(); } }
Example #29
Source File: FacebookSign.java From FeedFire with MIT License | 5 votes |
public void signIn(){ List<String> permissionNeeds= Arrays.asList("email", "public_profile"); LoginManager.getInstance().logInWithReadPermissions( mActivity, permissionNeeds); LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResults) { handleFacebookAccessToken(loginResults.getAccessToken()); } @Override public void onCancel() { if (mFaceCallback != null){ mFaceCallback.cancelLoginFace(); } } @Override public void onError(FacebookException e) { if (mFaceCallback != null){ mFaceCallback.errorLoginFace( e ); } } }); }
Example #30
Source File: FacebookHelper.java From argus-android with Apache License 2.0 | 5 votes |
public void initialize() { LoginManager.getInstance() .registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { GraphRequest graphRequest = GraphRequest .newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object, GraphResponse response) { token = AccessToken.getCurrentAccessToken(); if (resultListener != null) { resultListener.onSuccess(token); } } }); Bundle parameters = new Bundle(); graphRequest.setParameters(parameters); graphRequest.executeAsync(); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { resultListener.onFailure(error.getMessage()); } }); }