if(session.isOpen()), facebook login on android always returning false

前端 未结 4 1612
粉色の甜心
粉色の甜心 2020-12-15 08:25

I\'m trying to implement a simple activity in my android application where a user is asked to login via facebook so that the user\'s \'likes\' are retrieved. So obviously fi

4条回答
  •  时光说笑
    2020-12-15 08:55

    I had the similar problem it was the hashkey was wrong in facebook, by following the below code you can get the hash key that has been sent to facebook. Just copy this hashkey and replace it. It will start working.

        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) {
    
        }
    

提交回复
热议问题