本文整理汇总了Java中android.hardware.usb.UsbManager.getAccessoryList方法的典型用法代码示例。如果您正苦于以下问题:Java UsbManager.getAccessoryList方法的具体用法?Java UsbManager.getAccessoryList怎么用?Java UsbManager.getAccessoryList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.usb.UsbManager
的用法示例。
在下文中一共展示了UsbManager.getAccessoryList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import android.hardware.usb.UsbManager; //导入方法依赖的package包/类
public void setup(Context context) {
mManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
UsbAccessory[] accessoryList = mManager.getAccessoryList();
PendingIntent mPermissionIntent = PendingIntent.getBroadcast(context, 0,
new Intent(ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
context.registerReceiver(mUsbReceiver, filter);
mManager.requestPermission(accessoryList[0], mPermissionIntent);
if (accessoryList[0] != null) {
mAccessory = accessoryList[0];
if (mManager.hasPermission(mAccessory)) {
openAccessory(mAccessory);
}
}
}
示例2: checkForDJIAccessory
import android.hardware.usb.UsbManager; //导入方法依赖的package包/类
public void checkForDJIAccessory() {
mUsbManager = (UsbManager) BridgeApplication.getInstance().getSystemService(Context.USB_SERVICE);
UsbAccessory[] accessoryList = mUsbManager.getAccessoryList();
if (accessoryList != null
&& accessoryList.length > 0
&& !TextUtils.isEmpty(accessoryList[0].getManufacturer())
&& accessoryList[0].getManufacturer().equals("DJI")) {
BridgeApplication.getInstance().getBus().post(new RCConnectionEvent(true));
//Check permission
mAccessory = accessoryList[0];
if (mUsbManager.hasPermission(mAccessory)) {
Log.d(TAG, "RC CONNECTED");
} else {
Log.d(TAG, "NO Permission to USB Accessory");
DJIRemoteLogger.e(TAG, "NO Permission to USB Accessory");
//mUsbManager.requestPermission(mAccessory, null);
}
} else {
BridgeApplication.getInstance().getBus().post(new RCConnectionEvent(false));
Log.d(TAG, "RC DISCONNECTED");
}
}
示例3: getList
import android.hardware.usb.UsbManager; //导入方法依赖的package包/类
public String[] getList(Context context) {
mManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
UsbAccessory[] accessoryList = mManager.getAccessoryList();
String[] accessoryLists = new String[1];
for (int i = 0; i < accessoryLists.length; i++) {
accessoryLists[i] = accessoryList[i].getModel()
+ " v" + accessoryList[i].getVersion()
+ " by " + accessoryList[i].getManufacturer();
}
return accessoryLists;
}
示例4: usbAccessories
import android.hardware.usb.UsbManager; //导入方法依赖的package包/类
public ArrayList<UsbAccessory> usbAccessories(){
if(_usbAccessories==null){
_usbAccessories = new ArrayList<UsbAccessory>();
UsbManager usbManager = getUsbManager();
UsbAccessory accessories[] = usbManager.getAccessoryList();
if(accessories==null){
return _usbAccessories;
}
for(Integer i=0;i<accessories.length;i++){
_usbAccessories.add(accessories[i]);
}
}
return _usbAccessories;
}