Code example for PackageManager

Methods: queryIntentActivities

0
     * Tests whether the Intent has a receiver registered. This can be used to show/hide 
     * functionality (like Phone, SMS) 
     */ 
    public static boolean isIntentRegistered(Context context, Intent intent) {
        final PackageManager packageManager = context.getPackageManager();
        final List<ResolveInfo> receiverList = packageManager.queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return receiverList.size() > 0;
    } 
 
    /** 
     * Returns true if this device can be used to make phone calls 
     */ 
    public static boolean isPhone(Context context) {
        if (!sIsInitialized) initialize(context);
        // Is the device physically capabable of making phone calls? 
        return sIsPhone;
    } 
 
    private static void initialize(Context context) {
        final TelephonyManager telephonyManager = new TelephonyManager(context);