本文整理汇总了Java中com.facebook.AccessTokenTracker.startTracking方法的典型用法代码示例。如果您正苦于以下问题:Java AccessTokenTracker.startTracking方法的具体用法?Java AccessTokenTracker.startTracking怎么用?Java AccessTokenTracker.startTracking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.AccessTokenTracker
的用法示例。
在下文中一共展示了AccessTokenTracker.startTracking方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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());
}
示例3: 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();
}
示例4: 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();
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}