Key hash for Android-Facebook app

后端 未结 30 2695
误落风尘
误落风尘 2020-11-22 01:17

I\'m working on an Android app, in which I want to integrate a Facebook posting feature. I downloaded the Facebook-Android SDK, and I got the readme.md (text file) in there,

30条回答
  •  天涯浪人
    2020-11-22 01:38

    try this :

    • two way to get Hash Key Value

    1) get hash key from using command line (Official Doc : https://developers.facebook.com/docs/android/getting-started)

    keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl
    base64
    

    OR

    2) get hash key using code

      @Override
       protected void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.activity_main);
    
                //Hask Kay generation 
                 GetKeyHase();
        }
    
        private void GetKeyHase() {
                try {
                    PackageInfo info = getPackageManager().getPackageInfo("ADD YOUR PACKAGE NAME", PackageManager.GET_SIGNATURES);
                    for (Signature signature : info.signatures) {
                        MessageDigest md = (MessageDigest.getInstance("SHA"));
                        md.update(signature.toByteArray());
                        String hashkey_value = new String(Base64.encode(md.digest(), 0));
                        Log.e("hash key", hashkey_value);
                        //check you logcat hash key value
                    }
                }catch (Exception e) {
                    Log.e("exception", e.toString());
                }
            }
    

提交回复
热议问题