Created
June 6, 2020 12:04
-
-
Save ShivamKumarJha/774b5844ac1a9f5f19866aba83e2770d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| method to get app keyhash: | |
| First declare following val with you app package name from manifest. | |
| val appPackage = "com.XXX.XXX" | |
| Now add below code to onCreate method of your activity and check logcat after running the app: | |
| try { | |
| val info: PackageInfo = packageManager.getPackageInfo( | |
| appPackage, | |
| PackageManager.GET_SIGNATURES | |
| ) | |
| for (signature in info.signatures) { | |
| val md: MessageDigest = MessageDigest.getInstance("SHA") | |
| md.update(signature.toByteArray()) | |
| Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)) | |
| } | |
| } catch (e: PackageManager.NameNotFoundException) { | |
| } catch (e: NoSuchAlgorithmException) { | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment