protected static PackageInfo getPackageInfo(Context ctx) {
        try {
            return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Error getting package info.", e);
            return null;
        }
    }
protected static PackageInfo getPackageInfo ( Context ctx ) { try { return ctx . getPackageManager ( ) . getPackageInfo ( ctx . getPackageName ( ) , 0 ) ; } catch ( PackageManager . NameNotFoundException e ) { Log . e ( TAG , "Error getting package info." , e ) ; return null ; } }
Return the Application's PackageInfo if possible, or null.

@param ctx Android application context
@return the Application's PackageInfo if possible, or null