Facebook 身份验证与 Facebook 应用程序错误
我按照此处的说明进行操作,当 Facebook 应用程序运行时,它工作正常。未安装。当安装官方Facebook应用程序时,调用authorize
后不会调用回调,并且我没有取回令牌。安装应用程序后,会出现闪亮的登录屏幕(来自 Facebook 应用程序),如果没有安装,则会出现网络视图。 我搜索了很多,但每个教程都说我应该使用我链接的页面中的示例。我缺少什么?
// 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.");
}
});
}
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.");
}
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要重写 Activity 中的 onActivityResult 方法:
You need to override the onActivityResult method in your Activity: