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


Java DeviceService.getAPI方法代码示例

本文整理汇总了Java中com.connectsdk.service.DeviceService.getAPI方法的典型用法代码示例。如果您正苦于以下问题:Java DeviceService.getAPI方法的具体用法?Java DeviceService.getAPI怎么用?Java DeviceService.getAPI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.connectsdk.service.DeviceService的用法示例。


在下文中一共展示了DeviceService.getAPI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCapability

import com.connectsdk.service.DeviceService; //导入方法依赖的package包/类
/**
 * Get a capability with the highest priority from a device. If device doesn't have such
 * capability then returns null.
 * @param controllerClass type of capability
 * @return capability implementation
 */
public <T extends CapabilityMethods> T getCapability(Class<T> controllerClass) {
    T foundController = null;
    CapabilityPriorityLevel foundControllerPriority = CapabilityPriorityLevel.NOT_SUPPORTED;
    for (DeviceService service: services.values()) {
        if (service.getAPI(controllerClass) == null)
            continue;

        T controller = service.getAPI(controllerClass);
        CapabilityPriorityLevel controllerPriority = service.getPriorityLevel(controllerClass);

        if (foundController == null) {
            foundController = controller;
 
            if (controllerPriority == null || controllerPriority == CapabilityPriorityLevel.NOT_SUPPORTED) {
                Log.w(Util.T, "We found a mathcing capability class, but no priority level for the class. Please check \"getPriorityLevel()\" in your class");
            }
            foundControllerPriority = controllerPriority;
        }
        else if (controllerPriority != null && foundControllerPriority != null) {
            if (controllerPriority.getValue() > foundControllerPriority.getValue()) {
                foundController = controller;
                foundControllerPriority = controllerPriority;
            }
        }
    }

    return foundController;
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:35,代码来源:ConnectableDevice.java


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