close
只需要能跑Android即可拿到hash Key 不需要讓windows再額外安裝openssl,
key-hash-for-android-facebook-app no need to install any openssl on windows
In android project
Code:
PackageInfo info;
try{
info = getPackageManager().getPackageInfo("com.you.name",PackageManager.GET_SIGNATURES);
for(Signature signature : info.signatures)
{ MessageDigest md;
md =MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String KeyResult =new String(Base64.encode(md.digest(),0));//String something = new String(Base64.encodeBytes(md.digest()));
Log.e("hash key", KeyResult);
Toast.makeText(this,"My FB Key is \n"+ KeyResult , Toast.LENGTH_LONG ).show();
}
}catch(NameNotFoundException e1){Log.e("name not found", e1.toString());
}catch(NoSuchAlgorithmException e){Log.e("no such an algorithm", e.toString());
}catch(Exception e){Log.e("exception", e.toString());}
只需修改"com.you.name"這裡就可 必須修改成你的檔案package的名稱 ex: com.myproject.helloworld
其他錯誤就import一些必要標頭就可以正常使用了
![](https://imageproxy.pixnet.cc/imgproxy?url=https://pic.pimg.tw/oilcut123/1396158650-3261888711_n.png)
tips from:
http://stackoverflow.com/questions/2507898/how-to-pick-an-image-from-gallery-sd-card-for-my-app-in-android
全站熱搜