我有一个问题:我已经从Facebook sdk复制粘贴代码 我试图与Facebook建立联系。它只是不起作用...... 我真的很沮丧,我不知道还能做些什么。 请帮忙......谢谢!
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Request.newMeRequest(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
Toast.makeText(getApplicationContext(), "Hello " + user.getName() + "!", 1).show();
}
}
}).executeAsync();
}
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
答案 0 :(得分:0)
首先,非常感谢你" da_st" 问题是在keyhash不是正确的。 所以如果有人在我的代码中使用了我的问题
String TAG = "com.sromku.simple.fb.example";
PackageInfo info = context.getPackageManager().getPackageInfo(TAG,
PackageManager.GET_SIGNATURES);
for (Signature signature: info.signatures)
{
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String keyHash = Base64.encodeToString(md.digest(), Base64.DEFAULT);
Log.d(TAG, "keyHash: " + keyHash);