Headertab

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, 17 May 2016

Get Hashkey programatically


Hello guys if you want get hash key programmatically then use this method.


ActvityMain.java

 public class MainActivity extends ActionBarActivity  {
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    getHashKey() ;
       
    }

  public void getHashKey() {
    try {
        PackageInfo info = getActivity().getPackageManager().getPackageInfo("com.samset.sample”,
                PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("HASH KEY:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (PackageManager.NameNotFoundException e) {
    } catch (NoSuchAlgorithmException e) {
    }
}

}


output....