简体   繁体   中英

Hash key for android facebook app

I'm trying to generate Key hash to incorporate Facebook Application in my Apps.

The problem is that;

I'm actually getting the right key hash, but i'm still getting the wrong app key hash. (Maybe I'm not taking the right part from the whole key..)

Any help will be very appreciated, I'm pretty lost here...

Problem Fixed! :

Just needed to get rid of the "=" sign after copying the key from the CMD.

Please let us know how you are getting your Key-Hash. If from keytool , then let us know the procedure, may be we will be able to fix, what are your missing.

In the meantime you can use the following code to get the Key-Hash.

private void getAppKeyHash() {
    try {
        PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md;

            md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String something = new String(Base64.encode(md.digest(), 0));
            Log.d("Hash key", something);
        } 
    }
    catch (NameNotFoundException e1) {
        // TODO Auto-generated catch block
        Log.e("name not found", e1.toString());
    }

    catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        Log.e("no such an algorithm", e.toString());
    }
    catch (Exception e){
        Log.e("exception", e.toString());
    }

}

Now from the logcat you can find the Key-Hash. For more info Please check it form facebook-sdk

Problem Fixed! :

Just needed to get rid of the "=" sign after copying the key from the CMD.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM