Java Code Examples for com.facebook.login.LoginManager#getInstance()
The following examples show how to use
com.facebook.login.LoginManager#getInstance() .
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: 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 3
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 4
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"})); }
Example 5
Source File: AuthUtil.java From SEAL-Demo with MIT License | 5 votes |
/** * Allows to logout from Facebook account * * @param context the activity context */ private static void logoutFacebookAccount(Context context) { AccessToken.setCurrentAccessToken(null); if (LoginManager.getInstance() != null) { LoginManager.getInstance().logOut(); } ApplicationState.setIsKeysCreated(false); // delete all user info deleteUserTokenAndInfo(context); // load sign in Intent myIntent = new Intent(context, SignInActivity.class); ((Activity) context).startActivityForResult(myIntent, SIGN_IN_ACTIVITY_REQUEST_CODE); }
Example 6
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 7
Source File: LoginDialogFragment.java From openshop.io-android with MIT License | 5 votes |
public static void logoutUser() { LoginManager fbManager = LoginManager.getInstance(); if (fbManager != null) fbManager.logOut(); SettingsMy.setActiveUser(null); MainActivity.updateCartCountNotification(); MainActivity.invalidateDrawerMenuHeader(); }
Example 8
Source File: LoginButton.java From kognitivo with Apache License 2.0 | 4 votes |
LoginManager getLoginManager() { if (loginManager == null) { loginManager = LoginManager.getInstance(); } return loginManager; }
Example 9
Source File: FacebookImpl.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
@Override public void logout() { LoginManager login = LoginManager.getInstance(); login.logOut(); }
Example 10
Source File: FacebookHelper.java From q-municate-android with Apache License 2.0 | 3 votes |
private void initFacebook() { FacebookSdk.sdkInitialize(activity.getApplicationContext()); fbCallbackManager = CallbackManager.Factory.create(); fbLoginManager = LoginManager.getInstance(); this.fbAccessTokenTracker = new FBAccessTokenTracker(); }