Invalid Key hash with Facebook Android SDK

后端 未结 3 657
情歌与酒
情歌与酒 2021-02-06 18:21

I\'m trying to use Facebook Android SDK to develop a simple app with the Facebook Login Button. But i\'m having trouble with Key Hashes. I\'ve created both a debug key and a rel

3条回答
  •  野性不改
    2021-02-06 18:56

     try {
             PackageInfo info = getPackageManager().getPackageInfo("your package name", PackageManager.GET_SIGNATURES);
             for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash:", "KeyHash:  " + Base64.encodeToString(md.digest(), Base64.DEFAULT));
             }
          }
          catch (PackageManager.NameNotFoundException e) {
    
          }
          catch (NoSuchAlgorithmException e) {
    
          }
    

提交回复
热议问题