當前位置: 首頁>>代碼示例>>Java>>正文


Java UsbDevice.getDeviceName方法代碼示例

本文整理匯總了Java中android.hardware.usb.UsbDevice.getDeviceName方法的典型用法代碼示例。如果您正苦於以下問題:Java UsbDevice.getDeviceName方法的具體用法?Java UsbDevice.getDeviceName怎麽用?Java UsbDevice.getDeviceName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.hardware.usb.UsbDevice的用法示例。


在下文中一共展示了UsbDevice.getDeviceName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: UsbControlBlock

import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
/**
 * this class needs permission to access USB device before constructing
 * @param monitor
 * @param device
 */
public UsbControlBlock(final USBMonitor monitor, final UsbDevice device) {
	if (DEBUG) Log.i(TAG, "UsbControlBlock:constructor");
	mWeakMonitor = new WeakReference<USBMonitor>(monitor);
	mWeakDevice = new WeakReference<UsbDevice>(device);
	mConnection = monitor.mUsbManager.openDevice(device);
	final String name = device.getDeviceName();
	if (mConnection != null) {
		if (DEBUG) {
			final int desc = mConnection.getFileDescriptor();
			final byte[] rawDesc = mConnection.getRawDescriptors();
			Log.i(TAG, "UsbControlBlock:name=" + name + ", desc=" + desc + ", rawDesc=" + rawDesc);
		}
	} else {
		Log.e(TAG, "could not connect to device " + name);
	}
}
 
開發者ID:wjchen,項目名稱:AndroidUvcCameras,代碼行數:22,代碼來源:USBMonitor.java

示例2: onReceive

import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
    String deviceName = usbDevice.getDeviceName();
    if (UsbStorageProvider.ACTION_USB_PERMISSION.equals(action)) {
        boolean permission = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false);
        if (permission) {
            discoverDevice(usbDevice);
            notifyRootsChanged();
            notifyDocumentsChanged(getContext(), getRootId(usbDevice)+ROOT_SEPERATOR);
        } else {
            // so we don't ask for permission again
        }
    } else if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)
            || UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
        updateRoots();
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:20,代碼來源:UsbStorageProvider.java

示例3: retrieveAvailableUsbDevices

import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public static List<RtlSdrDevice> retrieveAvailableUsbDevices(final Context context) {
    final List<RtlSdrDevice> result = new LinkedList<>();
    if (usbSupported) {
        final Object usbManagerObj=context.getSystemService(Context.USB_SERVICE);
        if (usbManagerObj instanceof UsbManager) {
            final UsbManager manager = (UsbManager) usbManagerObj;
            retrieveSupportedDevices(context.getResources());

            final HashMap<String, UsbDevice> deviceList = manager.getDeviceList();

            for (final Map.Entry<String, UsbDevice> desc : deviceList.entrySet()) {
                final UsbDevice candidate = desc.getValue();
                final Pair<Integer, Integer> candidatePair = new Pair<>(candidate.getVendorId(), candidate.getProductId());

                SupportedDevice device = null;
                for (int i = 0; i < supportedDevices.size() && device == null; i++) {
                    final SupportedDevice supportedDevice = supportedDevices.get(i);
                    if (supportedDevice.getVendorAndProductId().equals(candidatePair)) {
                        device = supportedDevice;
                    }
                }

                if (device != null) {
                    final String friendlyName = candidate.getDeviceName() + " " + device.getDescription() + " (" + candidate.getVendorId() + ":" + candidate.getProductId() + ")";
                    result.add(new RtlSdrDevice(candidate, friendlyName));
                }
            }
        }
    }
    return result;
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:32,代碼來源:UsbUtils.java

示例4: getDeviceName

import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public String getDeviceName() {
	final UsbDevice device = mWeakDevice.get();
	return device != null ? device.getDeviceName() : "";
}
 
開發者ID:wjchen,項目名稱:AndroidUvcCameras,代碼行數:5,代碼來源:USBMonitor.java

示例5: getPath

import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public static String getPath(UsbDevice device){
    return device.getDeviceName();
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:4,代碼來源:UsbUtils.java

示例6: checkDevice

import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public void checkDevice(UsbDevice device){
    String deviceName = device.getDeviceName();
    int deviceId = device.getDeviceId();
    int deviceVID = device.getVendorId();
    int devicePID = device.getProductId();
    int type = 0;
    if(DEBUG) {
        Log.d(TAG, "-------------------");
        Log.d(TAG, "[UsbSerial] Found usb device");
        Log.d(TAG, "-------------------");
        Log.d(TAG, "DeviceName:" + deviceName);
        Log.d(TAG, "deviceId:" + deviceId);
        Log.d(TAG, "deviceVID:" + deviceVID);
        Log.d(TAG, "devicePID:" + devicePID);
        Log.d(TAG, "-------------------");
    }

    // Arduino
    if (deviceVID == FaBoUsbConst.ARDUINO_UNO_VID && devicePID == FaBoUsbConst.ARDUINO_UNO_PID) {
        deviceType = FaBoUsbConst.TYPE_ARDUINO_UNO;
    } else if (deviceVID == FaBoUsbConst.ARDUINO_CC_UNO_VID && devicePID == FaBoUsbConst.ARDUINO_CC_UNO_PID) {
        deviceType = FaBoUsbConst.TYPE_ARDUINO_CC_UNO;
    } else if (deviceVID == FaBoUsbConst.ARDUINO_LEONARDO_VID && devicePID == FaBoUsbConst.ARDUINO_LEONARDO_PID) {
        deviceType = FaBoUsbConst.TYPE_ARDUINO_LEONARDO;
    } else if (deviceVID == FaBoUsbConst.GENUINO_UNO_VID && devicePID == FaBoUsbConst.GENUINO_UNO_PID) {
        deviceType = FaBoUsbConst.TYPE_GENUINO_UNO;
    } else if (deviceVID == FaBoUsbConst.G27_VID && devicePID == FaBoUsbConst.G27_PID) {
        deviceType = FaBoUsbConst.TYPE_G27;
    } else {
        listener.onFind(device, FaBoUsbConst.TYPE_UNSUPPORTED);
        return;
    }

    Log.i(TAG, "mUsbManager.hasPermission(device):" + mUsbManager.hasPermission(device));

    if(!mUsbManager.hasPermission(device)) {
        if(!this.checkingFlag) {
            this.checkingFlag = true;
            PendingIntent mPermissionIntent = PendingIntent.getBroadcast(this.mContext, 0, new Intent(ACTION_USB_PERMISSION), 0);
            mUsbManager.requestPermission(device, mPermissionIntent);
        }
    } else {
        this.mDevice = device;
        listener.onFind(device, deviceType);
    }
}
 
開發者ID:FaBoPlatform,項目名稱:FaBo-Serial-Kit,代碼行數:47,代碼來源:FaBoUsbManager.java


注:本文中的android.hardware.usb.UsbDevice.getDeviceName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。