当前位置: 首页>>代码示例>>Java>>正文


Java UsbManager.getAccessoryList方法代码示例

本文整理汇总了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);
            }
        }

    }
 
开发者ID:victordiaz,项目名称:phonk,代码行数:21,代码来源:AdkPort.java

示例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");
    }
}
 
开发者ID:dji-sdk,项目名称:Android-Bridge-App,代码行数:23,代码来源:USBConnectionManager.java

示例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;
    }
 
开发者ID:victordiaz,项目名称:phonk,代码行数:16,代码来源:AdkPort.java

示例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;
}
 
开发者ID:GIGATeam,项目名称:UsbExtension,代码行数:15,代码来源:UsbContext.java


注:本文中的android.hardware.usb.UsbManager.getAccessoryList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。