@Nullable
  public static String getSigningCertificateSha1Fingerprint(@NotNull Context context) {
    final PackageManager pm = context.getPackageManager();
    if (pm == null) {
      return null;
    }

    // PackageManage.GET_SIGNATURES == 64
    PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 64);
    if (packageInfo == null) {
      return null;
    }

    Object signingSignature = packageInfo.signingSignature();
    if (signingSignature == null) {
      return null;
    }

    try {
      MessageDigest md = MessageDigest.getInstance("SHA-1");
      Class<?> signatureClass = Class.forName("android.content.pm.Signature");
      Method toByteArrayMethod = signatureClass.getMethod("toByteArray");
      byte[] byteArray = (byte[]) toByteArrayMethod.invoke(signingSignature);
      byte[] digest = md.digest(byteArray);
      return bytesToHex(digest);
    } catch (NoSuchAlgorithmException
        | ClassNotFoundException
        | IllegalAccessException
        | NoSuchMethodException
        | InvocationTargetException e) {
      return null;
    }
  }
Obtains the SHA-1 fingerprint of the certificate used to sign the app.

@param context a Context
@return the SHA-1 fingerprint if obtainable, otherwise, <code>null</code>
src/main/java/com/google/maps/android/CertificateHelper.java