Please anyone can tell me why this code do not return the result? It always stops in
( if is.open())
and gives false.
com.facebook.Session.openActiveSession(this, true, new com.facebook.Session.StatusCallback() {
@Override
public void call(com.facebook.Session session, SessionState state,
Exception exception) {
// TODO Auto-generated method stub
if (session.isOpened()) {
// make request to the /me API
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
TextView welcome = (TextView) findViewById(com.example.connectwithfacebook.R.id.textView1);
welcome.setText("Hello " + user.getName() + "!");
}
}
});
}
}
});
I implemented another way but I had then the same problem too.
It has to do with your hashkey within facebook. Run this code (make sure to change package name in 3rd line):
try {
PackageInfo info = getPackageManager().getPackageInfo(
"your.root.package",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
It will output the signature as "KeyHash:XXXXX" into logcat. Copy and paste that key into facebook and wil should start working.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments