當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。