当前位置: 首页>>代码示例>>Java>>正文


Java AccessTokenTracker类代码示例

本文整理汇总了Java中com.facebook.AccessTokenTracker的典型用法代码示例。如果您正苦于以下问题:Java AccessTokenTracker类的具体用法?Java AccessTokenTracker怎么用?Java AccessTokenTracker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AccessTokenTracker类属于com.facebook包,在下文中一共展示了AccessTokenTracker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerAccessTokenTracker

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
private static void registerAccessTokenTracker() {
    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(
                AccessToken oldAccessToken,
                AccessToken currentAccessToken) {
            if (oldAccessToken == null) {
                // If we never had an access token, then there would be no pending uploads.
                return;
            }

            if (currentAccessToken == null ||
                    !Utility.areObjectsEqual(
                            currentAccessToken.getUserId(),
                            oldAccessToken.getUserId())) {
                // Cancel any pending uploads since the user changed.
                cancelAllRequests();
            }
        }
    };
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:22,代码来源:VideoUploader.java

示例2: onCreate

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());

    callbackManager = CallbackManager.Factory.create();

    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {

        }
    };

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            //Toast.makeText(getActivity(), "newProfile", Toast.LENGTH_SHORT).show();
            //displayMessage(currentProfile);

        }
    };

    accessTokenTracker.startTracking();
    profileTracker.startTracking();
}
 
开发者ID:jtran064,项目名称:PlatePicks-Android,代码行数:27,代码来源:LoginFragment.java

示例3: setupFacebookLogin

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
private void setupFacebookLogin() {
    //TODO: Check if facebook login is actvated in the server
    String appId = FacebookSdk.getApplicationId();
    Timber.d("appId: " + appId);
    if (appId != null) {
        mCallbackManager = CallbackManager.Factory.create();
        mFacebookButton.setReadPermissions(PERMISSIONS);
        mFacebookButton.registerCallback(mCallbackManager, mFacebookCallback);
        mAccessTokenTracker = new AccessTokenTracker() {
            @Override
            protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
                if (currentAccessToken != null) {
                    mRxRocketMethods.loginWithFacebook(currentAccessToken.getToken(), currentAccessToken.getExpires().getTime() - new Date().getTime())
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .subscribe(mLoginSubscriber);

                }
            }
        };

    } else {
        mFacebookButton.setVisibility(View.GONE);
    }

}
 
开发者ID:lukamarin,项目名称:Rocket.Chat-android,代码行数:27,代码来源:LoginActivity.java

示例4: onCreate

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.splash_screen);
    FacebookSdk.sdkInitialize(getApplicationContext());

    AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) {
            updateWithToken(newAccessToken);
        }

    };
    accessTokenTracker.startTracking();
    updateWithToken(AccessToken.getCurrentAccessToken());
}
 
开发者ID:TeamSirius,项目名称:MaraudersMapMultiUser,代码行数:18,代码来源:SplashScreenActivity.java

示例5: onCreate

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();

    mAccessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
            if (currentAccessToken == null) {
                //logout from facebook
                EventBus.getDefault().post(new UserEvent.LogoutEvent());
            }
        }
    };
}
 
开发者ID:agpyaephyo,项目名称:Movie-Maniac-Android,代码行数:17,代码来源:BaseActivity.java

示例6: initAccessTokenTracker

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
private void initAccessTokenTracker() {
    mAccessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
            // Set the access token using
            // currentAccessToken when it's loaded or set.
            // If the access token is available already assign it.
            mFacebookAccessToken = AccessToken.getCurrentAccessToken();
            //                Toast.makeText(mActivity, "Facebook current Access Token changed", Toast.LENGTH_SHORT)
            //                        .show();
        }
    };
}
 
开发者ID:davideas,项目名称:AndroidBlueprints,代码行数:14,代码来源:FacebookHelper.java

示例7: initFacebook

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
private void initFacebook() {
    FacebookSdk.setApplicationId(Config.FACEBOOK_APP_ID);

    AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) {
            Logger.printInfo(LOG_TAG, "Is loged in with facebook");
        }
    };
    accessTokenTracker.startTracking();
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:12,代码来源:LoginMaster.java

示例8: setupTokenTracker

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
private void setupTokenTracker() {
    mTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
            Log.d("scion", "" + currentAccessToken);
        }
    };
}
 
开发者ID:scionoftech,项目名称:Material-Login,代码行数:9,代码来源:Login.java

示例9: login

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
@Override
public void login() {
    Log.d(TAG, "Login Facebook Account");
    final AccessTokenTracker tracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
            Log.d(TAG, "onCurrentAccessTokenChanged");
            this.stopTracking();
            loginFragment.startLoading();
            dataManager.getCredentials(new CredentialsListener() {
                @Override
                public void onSuccess(SocialMediaAccount account) {
                    loginFragment.stopLoading();

                    listener.onSuccess(account);
                }

                @Override
                public void onError(ServerStatusCode error) {
                    loginFragment.stopLoading();
                    listener.onError(error);
                }
            });
        }
    };
    Log.d(TAG, "Starting tracker");
    tracker.startTracking();
    LoginManager.getInstance().logInWithReadPermissions(loginFragment, Arrays.asList("email", "public_profile"));


    TranSappApplication.getAppSharedPreferences().edit().putBoolean(
            TranSappApplication.getAppContext().
                    getString(R.string.facebook_log_in), true
    ).apply();
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:36,代码来源:FacebookAccountLoginner.java

示例10: FacebookDelegate

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
public FacebookDelegate(UserHelper userHelper, Activity activity, String... permissions) {
    this.mUserHelper = userHelper;

    FacebookSdk.sdkInitialize(activity.getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();
    mActivity = activity;
    mPermissions = Arrays.asList(permissions);
    LoginManager.getInstance().registerCallback(mCallbackManager, this);

    mAccessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(
                AccessToken oldAccessToken,
                AccessToken currentAccessToken) {
            mAccessToken = AccessToken.getCurrentAccessToken();
        }
    };

    mProfileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(
                Profile oldProfile,
                Profile currentProfile) {
            if (currentProfile == null) {
                mUserHelper.setCurrentUser(null);

                // Logout
                if (oldProfile != null && mUserSessionCallback != null) {
                    mUserSessionCallback.onLogout();
                }
            } else {
                requestUserData();
            }
        }
    };

    // If the access token is available already assign it.
    mAccessToken = AccessToken.getCurrentAccessToken();
}
 
开发者ID:Michenux,项目名称:YourAppIdea,代码行数:40,代码来源:FacebookDelegate.java

示例11: onCreate

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
/**
 * Método de arranque. Se instancian todas las referencias del login con Google y Facebook.
 * @param savedInstanceState {Bundle}
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Se instancian las GoogleSignInOptions y el GoogleApiClient.
    googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestProfile()
            .build();

    if(googleApiClient == null) {
        googleApiClient = new GoogleApiClient.Builder(getActivity())
                .enableAutoManage(getActivity(), new GoogleApiClient.OnConnectionFailedListener() {
                    @Override
                    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                        OKDialog.showOKDialog(getActivity(), "Error", "Hubo un error en la conexión, reintentar más adelante");
                    }
                })
                .addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions).addApi(LocationServices.API)
                .build();
    }


    //Configuración de Facebook.
    callbackManager = CallbackManager.Factory.create();
    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) {

        }
    };
    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile newProfile) { }
    };
    accessTokenTracker.startTracking();
    profileTracker.startTracking();


    //Instancia de las preferencias.
    prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());


    //Instancia de retrofit para servicio de API
    retrofit = ((MyApplication) getActivity().getApplication()).getRetrofitInstance();
    usuarioAPI = retrofit.create(UsuarioAPI.class);

}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:53,代码来源:LoginFragment.java

示例12: initEntities

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
private void initEntities() {
    // ----- For sign in with email ----- //
    authListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                signInStatusMessage("Signed in: "
                        + "user.getDisplayName() " + user.getDisplayName() + " \n"
                        + "user.getUid() " + user.getUid() + " \n"
                        + "user.getProviderId() " + user.getProviderId() + " \n"
                );
                isSignedIn = true;
            } else {
                signInStatusMessage("Signed out.");
                isSignedIn = false;
            }
        }
    };


    // ----- For sign in with facebook ----- //
    btnFacebook.registerCallback(facebookCallbackManager, new FacebookCallback<LoginResult>(){
        @Override
        public void onSuccess(LoginResult loginResult) {
            isSignedIn = true;
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            isSignedIn = false;
        }

        @Override
        public void onError(FacebookException error) {
            isSignedIn = false;
        }
    });

    // ----- For sign OUT with facebook ----- //
    AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken accessToken, AccessToken accessToken2) {
            if (accessToken2 == null)  signOut();
        }
    };



    // ----- For sign in with google ----- //
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    googleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                    // nothing
                }
            })
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

}
 
开发者ID:andrewgrow,项目名称:Firebase-Login-Example-Project,代码行数:67,代码来源:MainActivity.java

示例13: addFacebookUserIdentity

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
protected void addFacebookUserIdentity(final CompletionCallback completionCallback) {
	final CompletionCallback wrapped = new CompletionCallback() {
		@Override
		public void onSuccess() {
			completionCallback.onSuccess();
			setFacebookDisplayName();
			setFacebookAvatar();
		}

		@Override
		public void onFailure(GetSocialException e) {
			completionCallback.onFailure(e);
		}
	};
	final AddUserIdentityOutcomeCallback addUserIdentityOutcomeCallback = new AddUserIdentityOutcomeCallback() {
		@Override
		public void onSuccess() {
			_log.logInfoAndToast("Added Facebook identity successfully");
			wrapped.onSuccess();
		}

		@Override
		public void onFailure(Throwable throwable) {
			_log.logInfoAndToast("Adding Facebook identity failed : " + throwable);
			disconnectFromFacebook();
			wrapped.onFailure(upgradeToGetSocialException(throwable));
		}

		@Override
		public void onConflictResolvedWithCurrent() {
			_log.logInfoAndToast("Conflict adding Facebook user identity resolved with current");
			disconnectFromFacebook();
		}

		@Override
		public void onConflictResolvedWithRemote() {
			_log.logInfoAndToast("Conflict adding Facebook user identity resolved with remote");
			wrapped.onSuccess();
		}
	};

	final AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
		@Override
		protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, @Nullable AccessToken newAccessToken) {

			if (newAccessToken == null) {
				addUserIdentityOutcomeCallback.onFailure(new IllegalStateException("Facebook SDK did not provide an AccessToken"));
				return;
			}

			stopTracking();

			final String tokenString = newAccessToken.getToken();

			addIdentity(AuthIdentity.createFacebookIdentity(tokenString), addUserIdentityOutcomeCallback);
		}
	};
	accessTokenTracker.startTracking();
	LoginManager.getInstance().logInWithReadPermissions(getActivity(), FACEBOOK_PERMISSIONS);
}
 
开发者ID:getsocial-im,项目名称:getsocial-android-sdk,代码行数:61,代码来源:BaseFragment.java

示例14: load

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
@Override
public void load(final CredentialsListener listener) {
    Log.d(TAG, "Loading account");
    boolean hasFacebookLoggedIn =
            TranSappApplication.getAppSharedPreferences()
                    .getBoolean(
                            TranSappApplication.getAppContext().
                                    getString(R.string.facebook_log_in), false);

    if (!hasFacebookLoggedIn) {
        Log.d(TAG, "First time login");
        listener.onError(new ServerStatusCode(ServerStatusCode.LOGIN_API_ERROR));
        return;
    }

    if (AccessToken.getCurrentAccessToken() != null) {
        Log.d(TAG, "loadDataFromToken");
        dataManager.getCredentials(listener);
        return;
    }
    final Timer timer = new Timer();
    final AccessTokenTracker tracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken,
                                                   AccessToken currentAccessToken) {
            timer.cancel();
            stopTracking();
            if (currentAccessToken == null) {
                Log.d(TAG, "Facebook logged out");
                listener.onError(new ServerStatusCode(ServerStatusCode.LOGIN_API_ERROR));
            } else {
                Log.d(TAG, "Facebook logged in");
                dataManager.getCredentials(listener);
            }
        }
    };

    Log.d(TAG, "Starting tracker");
    tracker.startTracking();
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            tracker.stopTracking();
            Log.d(TAG, "Time up");
            listener.onError(new ServerStatusCode(ServerStatusCode.LOGIN_API_ERROR));
        }
    }, 5000);
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:49,代码来源:FacebookAccountLoader.java

示例15: getFacebookAccessTokenTracker

import com.facebook.AccessTokenTracker; //导入依赖的package包/类
/**
 * Gets facebook access token tracker.
 *
 * @return the facebook access token tracker
 */
public AccessTokenTracker getFacebookAccessTokenTracker() {
    return this.mAccessTokenTracker;
}
 
开发者ID:davideas,项目名称:AndroidBlueprints,代码行数:9,代码来源:FacebookHelper.java


注:本文中的com.facebook.AccessTokenTracker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。