How to get user basic info from FaceBook SDK in android?

164 views Asked by At

I am trying to get the user info from FaceBook using FaceBook sdk in android.

I was able o login successfully. I am trying to get the user info from answer provided in the following link and I am getting the following error.

Please provide how to go further from here. enter image description here

I did not any error for the first time but I am getting the above error from the second time onwards.

1

There are 1 answers

0
Mukesh Rana On

The error shows that you have forgot to include your hashkey in facebook developer page of your app. Try this code in onCreate of your Activity to get your Hashkey

try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.example.packagename", 
            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) {

}

the KehHash is generated in the logcat and you should copy and paste that in facebook developer page of your app.Also don't forget to use correct app_id in your project. Refer this link for more info.