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 ; }
Query the signature for the application that would be invoked by the given intent and verify that it matches the FB application s signature .