Facebook认证与Facebook应用程序错误
我遵循此处的说明,并且可以正常工作,当没有安装Facebook App。当安装官方的Facebook应用程序时,调用 authorize
后,不会调用回调,并且我没有收回令牌。当安装该应用程序时,闪亮的登录屏幕出现(从Facebook应用程序),而不是Webview。
我搜索了很多,但每个教程都说我应该使用我链接的页面中的样本。我缺少什么?
I followed the instructions here, and it works fine, when the Facebook App is not installed. When the official Facebook App is installed, the callback are not called after calling authorize
, and I don't get back the token. When the app is installed, the shiny login screen comes up (from the Facebook app), when it's not, the webview.
I searched a lot, but every tutorial says I should use the sample from the page I linked. What am I missing?
// Facebook connect
public void facebookConnect(View v) {
/* CocktailflowTest AppID */
final Facebook facebook = new Facebook("134370943293463");
facebook.authorize(this, new String[] { "email", "offline_access" }, new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
e.getMessage();
}
@Override
public void onError(DialogError e) {
Toast.makeText(LaunchActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
public void onComplete(Bundle values) {
mFBToken = facebook.getAccessToken();
getPreferences(MODE_PRIVATE).edit().putString(Prefs.FACEBOOK_TOKEN, mFBToken).commit();
WebService service = new WebService();
WebServiceListener l = new LaunchWebserviceListener();
mDialog = ProgressDialog.show(LaunchActivity.this, "", "Logging in...");
mDialog.show();
service.connectWithFacebook(l, mFBToken);
}
@Override
public void onCancel() {
Log.i(TAG, "Facebook connect was cancelled by user.");
}
});
}
您需要覆盖onActivityResult您的活动中的方法:
You need to override the onActivityResult method in your Activity:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}