本文整理匯總了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;
}