Key hash for Facebook Android SDK

前端 未结 9 1949
后悔当初
后悔当初 2020-11-28 03:29

I can\'t figure out how to get the Key Hash required to use the Facebook Android SDK. I figured out that I can use keytool with these commands:

         


        
9条回答
  •  我在风中等你
    2020-11-28 04:11

    you can use code below to get the Hash key :

    try {
    
       PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 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) {
       Log.e("name not found", e.toString());
      } catch (NoSuchAlgorithmException e) {
       Log.e("no such an algorithm", e.toString());
      }
    

    Reference :

    http://limbaniandroid.blogspot.com/2013/04/how-to-get-hash-key-for-integarte.html

提交回复
热议问题