com.facebook.login.LoginManager Java Examples
The following examples show how to use
com.facebook.login.LoginManager.
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: MainActivity.java From firebase-login-demo-android with MIT License | 6 votes |
/** * Unauthenticate from Firebase and from providers where necessary. */ private void logout() { if (this.mAuthData != null) { /* logout of Firebase */ mFirebaseRef.unauth(); /* Logout of any of the Frameworks. This step is optional, but ensures the user is not logged into * Facebook/Google+ after logging out of Firebase. */ if (this.mAuthData.getProvider().equals("facebook")) { /* Logout from Facebook */ LoginManager.getInstance().logOut(); } else if (this.mAuthData.getProvider().equals("google")) { /* Logout from Google+ */ if (mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); mGoogleApiClient.disconnect(); } } /* Update authenticated user and show login buttons */ setAuthenticatedUser(null); } }
Example #3
Source File: FbLoginHiddenActivity.java From SocialLoginManager with Apache License 2.0 | 6 votes |
@Override public void onCompleted(JSONObject object, GraphResponse response) { try { SocialUser user = new SocialUser(); user.userId = object.getString("id"); user.accessToken = AccessToken.getCurrentAccessToken().getToken(); user.photoUrl = String.format(PHOTO_URL, user.userId); SocialUser.Profile profile = new SocialUser.Profile(); profile.email = object.has("email")? object.getString("email") : ""; profile.name = object.has("name")? object.getString("name"): ""; profile.pageLink = object.has("link")? object.getString("link"): ""; user.profile = profile; SocialLoginManager.getInstance(this).onLoginSuccess(user); } catch (JSONException e) { SocialLoginManager.getInstance(this).onLoginError(e.getCause()); } LoginManager.getInstance().logOut(); finish(); }
Example #4
Source File: ProductsActivity.java From android-paypal-example with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_contact_us) { contactUs(); return true; }else if (id == R.id.action_logout) { //facebook logout LoginManager.getInstance().logOut(); //firebase logout FirebaseAuth.getInstance().signOut(); logout = true; startActivity(new Intent(this,LoginActivity.class)); return true; }else if (id == R.id.item_samplebadge) { Intent intent = new Intent(this,ShoppingCardActivity.class); intent.putParcelableArrayListExtra("order",cardItems); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
Example #5
Source File: AccountNavigator.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
public AccountNavigator(BottomNavigationNavigator bottomNavigationNavigator, FragmentNavigator fragmentNavigator, AptoideAccountManager accountManager, ActivityNavigator activityNavigator, LoginManager facebookLoginManager, CallbackManager callbackManager, GoogleApiClient client, PublishRelay<FacebookLoginResult> facebookLoginSubject, String recoverPasswordUrl, AccountAnalytics accountAnalytics, ThemeManager themeManager) { this.bottomNavigationNavigator = bottomNavigationNavigator; this.fragmentNavigator = fragmentNavigator; this.accountManager = accountManager; this.activityNavigator = activityNavigator; this.facebookLoginManager = facebookLoginManager; this.callbackManager = callbackManager; this.client = client; this.facebookLoginSubject = facebookLoginSubject; this.recoverPasswordUrl = recoverPasswordUrl; this.accountAnalytics = accountAnalytics; this.themeManager = themeManager; }
Example #6
Source File: ApplicationModule.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Singleton @Provides AptoideAccountManager provideAptoideAccountManager(AdultContent adultContent, GoogleApiClient googleApiClient, StoreManager storeManager, AccountService accountService, LoginPreferences loginPreferences, AccountPersistence accountPersistence, @Named("facebookLoginPermissions") List<String> facebookPermissions) { FacebookSdk.sdkInitialize(application); return new AptoideAccountManager.Builder().setAccountPersistence( new MatureContentPersistence(accountPersistence, adultContent)) .setAccountService(accountService) .setAdultService(adultContent) .registerSignUpAdapter(GoogleSignUpAdapter.TYPE, new GoogleSignUpAdapter(googleApiClient, loginPreferences)) .registerSignUpAdapter(FacebookSignUpAdapter.TYPE, new FacebookSignUpAdapter(facebookPermissions, LoginManager.getInstance(), loginPreferences)) .setStoreManager(storeManager) .build(); }
Example #7
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 #8
Source File: LoginMaster.java From uPods-android with Apache License 2.0 | 6 votes |
public void logout() { if (AccessToken.getCurrentAccessToken() != null) { LoginManager.getInstance().logOut(); Logger.printInfo(LOG_TAG, "Loged out from facebook"); } if (Twitter.getSessionManager().getActiveSession() != null) { Twitter.getSessionManager().clearActiveSession(); Twitter.logOut(); Logger.printInfo(LOG_TAG, "Loged out from twitter"); } if (VKSdk.isLoggedIn()) { VKSdk.logout(); Logger.printInfo(LOG_TAG, "Loged out from vk"); } Prefs.remove(SyncMaster.GLOBAL_TOKEN); userProfile = new UserProfile(); }
Example #9
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 #10
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 #11
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 #12
Source File: LoginActivity.java From android with MIT License | 6 votes |
private void logoutIfNecessary() { PrkngPrefs.getInstance(this).setAuthUser(null); LoginManager.getInstance().logOut(); if (mGoogleApiClient != null) { mGoogleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(Bundle bundle) { Auth.GoogleSignInApi.signOut(mGoogleApiClient); } @Override public void onConnectionSuspended(int i) { } }); } }
Example #13
Source File: profile.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); btnFBLogout = findViewById(R.id.btnlogout); tvid = findViewById(R.id.tvId); mAuth = FirebaseAuth.getInstance(); FirebaseUser user = mAuth.getCurrentUser(); //String id = user. // tvid.setText(id); btnFBLogout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mAuth.signOut();//firebase LoginManager.getInstance().logOut();//facebook updateUI(); } }); }
Example #14
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 #15
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 #16
Source File: FacebookImpl.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void askPublishPermissions(final LoginCallback cb) { if (AndroidNativeUtil.getActivity() == null) { throw new RuntimeException("Cannot ask for publish permissions when running in the background."); } if (loginLock) { return; } loginLock = true; LoginManager login = LoginManager.getInstance(); final CallbackManager mCallbackManager = CallbackManager.Factory.create(); final CodenameOneActivity activity = (CodenameOneActivity) AndroidNativeUtil.getActivity(); activity.setIntentResultListener(new IntentResultListener() { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { mCallbackManager.onActivityResult(requestCode, resultCode, data); activity.restoreIntentResultListener(); } }); login.registerCallback(mCallbackManager, new FBCallback(cb)); login.logInWithPublishPermissions(activity, PUBLISH_PERMISSIONS); }
Example #17
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 #18
Source File: UserServiceAndroidExtra.java From Android-SDK with MIT License | 6 votes |
void loginWithFacebookSdk( final android.app.Activity context, final Map<String, String> facebookFieldsMappings, List<String> permissions, CallbackManager callbackManager, final AsyncCallback<BackendlessUser> responder ) { LoginManager.getInstance().registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess( LoginResult loginResult ) { getBackendlessUser( loginResult.getAccessToken(), facebookFieldsMappings, responder ); } @Override public void onCancel() { responder.handleFault( new BackendlessFault( ExceptionMessage.FACEBOOK_LOGINNING_CANCELED ) ); } @Override public void onError( FacebookException exception ) { responder.handleFault( new BackendlessFault( ExceptionMessage.NULL_GRAPH_USER ) ); } } ); LoginManager.getInstance().logInWithReadPermissions( context, permissions ); }
Example #19
Source File: ActivityModule.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@ActivityScope @Provides AccountNavigator provideAccountNavigator( @Named("main-fragment-navigator") FragmentNavigator fragmentNavigator, AptoideAccountManager accountManager, CallbackManager callbackManager, GoogleApiClient googleApiClient, AccountAnalytics accountAnalytics, BottomNavigationNavigator bottomNavigationNavigator, ThemeManager themeManager) { return new AccountNavigator(bottomNavigationNavigator, fragmentNavigator, accountManager, ((ActivityNavigator) activity), LoginManager.getInstance(), callbackManager, googleApiClient, PublishRelay.create(), "http://m.aptoide.com/account/password-recovery", accountAnalytics, themeManager); }
Example #20
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 #21
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 5 votes |
/** * Sign in to google account - without Google's log in button. * * @param activity the activity * @param callback the callback to receive the method's result */ public void signIn(@NonNull Activity activity, @NonNull final FacebookLoginResultCallback callback) { mCallbackManager = CallbackManager.Factory.create(); mFacebookLoginResultCallBack = callback; registerCallBackManager(activity); LoginManager.getInstance() .setLoginBehavior(LoginBehavior.NATIVE_WITH_FALLBACK) .logInWithPublishPermissions(activity, null); }
Example #22
Source File: FbLoginHiddenActivity.java From SocialLoginManager with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, this); LoginManager.getInstance().logOut(); if (SocialLoginManager.getInstance(this).isWithProfile()) { LoginManager.getInstance().logInWithReadPermissions(this, PERMISSIONS); } else { LoginManager.getInstance().logInWithReadPermissions(this, null); } }
Example #23
Source File: AndroidGDXFacebook.java From gdx-facebook with Apache License 2.0 | 5 votes |
@Override protected void startGUISignIn() { Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Starting GUI sign in."); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { accessToken = new GDXFacebookAccessToken(AccessToken.getCurrentAccessToken().getToken(), AccessToken.getCurrentAccessToken().getExpires().getTime()); storeNewToken(accessToken); Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Sign in successful. User token: " + accessToken.getToken()); callback.onSuccess(new SignInResult(accessToken, "Sign in successful.")); } @Override public void onCancel() { Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Sign fail by user."); callback.onCancel(); } @Override public void onError(FacebookException e) { Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Error while trying to sign in: " + e.getMessage()); callback.onError(new GDXFacebookError(e.getMessage())); } }); if (this.signInMode == SignInMode.PUBLISH) { LoginManager.getInstance().logInWithPublishPermissions(activity, gdxArrayToCollection(permissions)); } else { LoginManager.getInstance().logInWithReadPermissions(activity, gdxArrayToCollection(permissions)); } }
Example #24
Source File: AndroidGDXFacebook.java From gdx-facebook with Apache License 2.0 | 5 votes |
@Override public void signOut(boolean keepSessionData) { super.signOut(keepSessionData); userId = null; FacebookSdk.sdkInitialize(activity.getApplicationContext()); LoginManager.getInstance().logOut(); if (keepSessionData == SignOutMode.DELETE_SESSION_DATA) { AccessToken.setCurrentAccessToken(null); deleteTokenData(); } }
Example #25
Source File: FacebookSignInHandler.java From FirebaseUI-Android with Apache License 2.0 | 5 votes |
@Override protected void onCreate() { List<String> permissions = getArguments().getParams() .getStringArrayList(ExtraConstants.FACEBOOK_PERMISSIONS); permissions = new ArrayList<>( permissions == null ? Collections.<String>emptyList() : permissions); // Ensure we have email and public_profile permissions if (!permissions.contains(EMAIL)) { permissions.add(EMAIL); } if (!permissions.contains(PUBLIC_PROFILE)) { permissions.add(PUBLIC_PROFILE); } mPermissions = permissions; LoginManager.getInstance().registerCallback(mCallbackManager, mCallback); }
Example #26
Source File: LoginWithFacebookSDKActivity.java From Android-SDK with MIT License | 5 votes |
private void logoutFromFacebook() { if (!isLoggedInFacebook) return; if (AccessToken.getCurrentAccessToken() != null) LoginManager.getInstance().logOut(); isLoggedInFacebook = false; fbAccessToken = null; socialAccountInfo.setTextColor(getColor(android.R.color.black)); socialAccountInfo.setText(""); }
Example #27
Source File: FacebookLogin.java From Android-Smart-Login with Apache License 2.0 | 5 votes |
@Override public boolean logout(Context context) { try { SharedPreferences preferences = context.getSharedPreferences(Constants.USER_PREFS, Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); LoginManager.getInstance().logOut(); editor.remove(Constants.USER_TYPE); editor.remove(Constants.USER_SESSION); editor.apply(); return true; } catch (Exception e) { Log.e("FacebookLogin", e.getMessage()); return false; } }
Example #28
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 #29
Source File: RxFacebookAuthFragment.java From RxSocialAuth with Apache License 2.0 | 5 votes |
/** * Facebook sign out */ public void signOut(PublishSubject<RxStatus> statusSubject) { LoginManager.getInstance().logOut(); // delete current user deleteCurrentUser(); statusSubject.onNext(new RxStatus( CommonStatusCodes.SUCCESS, getString(R.string.status_success_log_out_message) )); statusSubject.onCompleted(); }
Example #30
Source File: FaceBookManager.java From FimiX8-RE with MIT License | 5 votes |
public void login(Context context, final LoginCallback callback) { this.loginCallback = callback; this.mCallbackManager = Factory.create(); FacebookSdk.sdkInitialize(context); this.loginManager = LoginManager.getInstance(); this.loginManager.registerCallback(this.mCallbackManager, new FacebookCallback<LoginResult>() { public void onSuccess(LoginResult loginResult) { GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphJSONObjectCallback() { public void onCompleted(JSONObject object, GraphResponse response) { Log.i(FaceBookManager.TAG, "onCompleted: "); if (object != null) { Map<String, String> map = new HashMap(); map.put("name", object.optString("name")); map.put(BlockInfo.KEY_UID, object.optString("id")); FaceBookManager.this.loginCallback.loginSuccess(map); } } }).executeAsync(); } public void onCancel() { Log.i(FaceBookManager.TAG, "onCancel: "); } public void onError(FacebookException error) { Log.i(FaceBookManager.TAG, "onError: "); callback.loginFail(error.getMessage()); } }); LoginManager.getInstance().logInWithReadPermissions((Activity) context, Arrays.asList(new String[]{"public_profile", "user_friends"})); }