Android Facebook SDK: generate release key hash

后端 未结 11 1932
执念已碎
执念已碎 2020-12-04 14:49

I\'m building an app in which users can log in with Facebook.

I\'ve created the hash keys like following:

try {
         PackageInfo info = getPackag         


        
11条回答
  •  北海茫月
    2020-12-04 15:03

    // add this method to your first activity and open log and search for Base64 tag this is the Hashkey i hoop it help

    public void getHashkey(){
        try {
            PackageInfo info = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
    
                Log.i("Base64", Base64.encodeToString(md.digest(),Base64.NO_WRAP));
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.d("Name not found", e.getMessage(), e);
    
        } catch (NoSuchAlgorithmException e) {
            Log.d("Error", e.getMessage(), e);
        }
    }
    

提交回复
热议问题