Code example for PackageManager

Methods: hasSystemFeature

0
 
    public UsbService(Context context) {
        mContext = context;
        mSettingsManager = new UsbSettingsManager(context);
        PackageManager pm = mContext.getPackageManager();
        if (pm.hasSystemFeature(PackageManager.FEATURE_USB_HOST)) {
            mHostManager = new UsbHostManager(context, mSettingsManager);
        } 
        if (new File("/sys/class/android_usb").exists()) {
            mDeviceManager = new UsbDeviceManager(context, mSettingsManager);
        } 
    } 
 
    public void systemReady() { 
        if (mDeviceManager != null) {
            mDeviceManager.systemReady();
        } 
        if (mHostManager != null) {
            mHostManager.systemReady();
        } 
    }