在 android studio 中通过 Facebook api 4.0 解析登录 [英] parse login through Facebook api 4.0 in android studio
问题描述
我的代码是.
private void facebook() {
List<String> permissions = Arrays.asList("public_profile", "email");
ParseFacebookUtils.logInWithReadPermissionsInBackground(this, permissions, new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
progressDialog.dismiss();
Log.e("Facebook", user + " " + err.getMessage());
if (user == null) {
Log.e("MyApp", "Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew()) {
Log.e("MyApp", "User signed up and logged in through Facebook!");
} else {
userinfo(user);
Log.e("MyApp", "User logged in through Facebook!");
}
}
});
}
此代码始终提供用户为空..我使用了最新的 Facebook SDK
是
this code is always provided user is null..
I have use latest Facebook SDK
is
编译'com.facebook.android:facebook-android-sdk:4.0.1'
和Parse
是:Parse-1.9.1.jar
而且我使用了 Android Studio
.当单击按钮时调用此方法此方法有效意味着 facebook 弹出窗口已打开但它始终提供用户为空.这是给定的用户为空但刷新后 parseuser
不为空.
and I have use Android Studio
.
this method is call when click the button this method is work means facebook popup is open but it always provide user is null. This given is user is null but after refresh parseuser
is not null.
推荐答案
不确定,但请检查 https:/上的 Key Hash 设置/developers.facebook.com 用于您的应用.您需要在应用程序开发者控制台中设置发布和调试版本的密钥哈希.可能是您刚刚为调试环境设置了密钥散列.有关更多信息,请参阅设置发布密钥哈希.希望有帮助.
Not sure but check the Key Hash settings on https://developers.facebook.com for your app. You need to have both key hashes for release and debug version set in app developer console. It might be that you've just set the key hash for the debug environment. For more see Setting a Release Key Hash. Hope it helps.
ParseFacebookUtils.logInWithReadPermissionsInBackground(this, Arrays.asList("email", "user_photos", "public_profile", "user_friends")
, new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
if (user == null) {
Toast.makeText(Form.this,"User Already logged up through Twitter!",Toast.LENGTH_LONG).show();
} else if (user.isNew()) {
} else {
Toast.makeText(Form.this,"User Already logged up through Facebook!",Toast.LENGTH_LONG).show();
}
}
});
也添加这个..
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ParseFacebookUtils.onActivityResult(requestCode, resultCode, data);
}
此代码运行良好..
这篇关于在 android studio 中通过 Facebook api 4.0 解析登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!