Android facebook sdk 4.0 ProfileTracker onCurrentProfileChanged从未被调用
我正在尝试使用新的Facebook sdk版本4.5跟踪ProfileTracker类的用户配置文件。当用户在我的应用程序中使用Facebook登录(并且设备中安装了Facebook本机应用程序)时,它将使用本机应用程序中的当前用户帐户成功登录。但现在,如果用户从设备中的本机Facebook应用程序中注销,并使用上一个用户帐户以外的其他用户帐户登录。我希望我的应用程序得到通知,现在用户已经在本机应用程序中更改了他的帐户/配置文件。要确保我正在使用以下代码:Android facebook sdk 4.0 ProfileTracker onCurrentProfileChanged从未被调用,android,facebook,facebook-graph-api,facebook-sdk-4.0,Android,Facebook,Facebook Graph Api,Facebook Sdk 4.0,我正在尝试使用新的Facebook sdk版本4.5跟踪ProfileTracker类的用户配置文件。当用户在我的应用程序中使用Facebook登录(并且设备中安装了Facebook本机应用程序)时,它将使用本机应用程序中的当前用户帐户成功登录。但现在,如果用户从设备中的本机Facebook应用程序中注销,并使用上一个用户帐户以外的其他用户帐户登录。我希望我的应用程序得到通知,现在用户已经在本机应用程序中更改了他的帐户/配置文件。要确保我正在使用以下代码: protected void onCr
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_homescreen);
uIint();
LoginManager.getInstance().registerCallback(callbackManager, this);
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
if (oldProfile != null) {
Log.i(getClass().getSimpleName(), "profile oldProfile: " + oldProfile.getFirstName());
}
if (currentProfile != null) {
Log.i(getClass().getSimpleName(), "profile currentProfile: " + currentProfile.getFirstName());
}
}
};
profileTracker.startTracking();
if(profileTracker.isTracking())
Log.i(getClass().getSimpleName(), "profile currentProfile Tracking: " + "yes");
else
Log.i(getClass().getSimpleName(), "profile currentProfile Tracking: " + "no");
}
@Override
public void onSuccess(LoginResult loginResult) {
//Utils.showToast_msg(context, "Login success");
getFbProfileInfo();
}
@Override
public void onCancel() {
Utils.showToast_msg(context, "Login onCancel");
}
@Override
public void onError(FacebookException e) {
Utils.showToast_msg(context, "Login onError");
}
我在本机Fb应用程序中使用帐户登录,然后在我的应用程序中使用Fb成功登录。然后我从本机Fb应用程序注销并使用另一个帐户登录,但onCurrentProfileChanged从未被调用通知我配置文件已更改。我打印一个日志来检查它是否跟踪配置文件,它总是返回true/yes。任何帮助?只有当您使用LoginManager.getInstance().logOut()
显式注销用户,然后尝试使用的logIn
方法向Facebook验证该用户时,才会调用该帮助
你的应用程序不会意识到用户已登录Facebook本机应用程序中的另一个帐户,只会查看用于登录你的应用程序的
配置文件,而不会查看应用程序之外的内容。你不应该调用LoginManager.getInstance().logInWithReadPermissions(…)
来启动登录过程吗?