code: private boolean validateAppSignatureForPackage(Context context, String packageName) {
  
          PackageInfo packageInfo;
          try {
              packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
          } catch (NameNotFoundException e) {
              return false;
          }
  
          for (Signature signature : packageInfo.signatures) {
              if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
                  return true;
              }
          }
          return false;
      }
docs: Query the signature for the application that would be invoked by the
  given intent and verify that it matches the FB application's signature.
  
  @param context
  @param packageName
  @return true if the app's signature matches the expected signature.