本文整理匯總了Java中android.hardware.usb.UsbDevice.getDeviceId方法的典型用法代碼示例。如果您正苦於以下問題:Java UsbDevice.getDeviceId方法的具體用法?Java UsbDevice.getDeviceId怎麽用?Java UsbDevice.getDeviceId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.usb.UsbDevice
的用法示例。
在下文中一共展示了UsbDevice.getDeviceId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFind
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
@Override
public void onFind(int type, UsbDevice device) {
// Find Arduino
if(type == TestConst.TEST_TYPE) {
if(arduinoDeviceId1 == 0) {
mFaBoUsbMangerArduino1.connection(device);
arduinoDeviceId1 = device.getDeviceId();
} else if(arduinoDeviceId2 == 0) {
mFaBoUsbMangerArduino2.connection(device);
arduinoDeviceId2 = device.getDeviceId();
}
}
}
示例2: BaseInfo
import android.hardware.usb.UsbDevice; //導入方法依賴的package包/類
public BaseInfo(Context context, BaselineInitiator initiator, Integer userUniqueId)
{
this.context = context;
libVersion = initLibVersion();
androidDeviceUniqueId = initAndroidDevicerUniqueId();
androidOSVer = initAndroidOSVer();
androidUserUniqueId = userUniqueId;
androidDeviceInfo = Build.DEVICE.toString();
Log.d(TAG, "get android os ver " + androidOSVer);
Log.d(TAG, "android uuid is " + androidDeviceUniqueId);
Log.d(TAG, "libversion is " + libVersion);
if (initiator != null) {
UsbDevice device = initiator.getDevice();
if (device != null) {
vendorId = device.getVendorId();
deviceId = device.getDeviceId();
serial = device.getSerialNumber();
} else {
vendorId = -1;
deviceId = -1;
serial = "empty";
}
try {
deviceInfo = initiator.getDeviceInfo().toString();
} catch (Exception e) {
e.printStackTrace();
// ignore it
deviceInfo = "Exception when get device info";
}
} else {
vendorId = -1;
deviceId = -1;
serial = "empty";
}
}
示例3: 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);
}
}