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


Java ConnectableDeviceStore类代码示例

本文整理汇总了Java中com.connectsdk.device.ConnectableDeviceStore的典型用法代码示例。如果您正苦于以下问题:Java ConnectableDeviceStore类的具体用法?Java ConnectableDeviceStore怎么用?Java ConnectableDeviceStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DiscoveryManager

import com.connectsdk.device.ConnectableDeviceStore; //导入依赖的package包/类
/**
 * Create a new instance of DiscoveryManager.
 * Direct use of this constructor is not recommended. In most cases,
 * you should use DiscoveryManager.getInstance() instead.
 */
public DiscoveryManager(Context context, ConnectableDeviceStore connectableDeviceStore) {
    this.context = context;
    this.connectableDeviceStore = connectableDeviceStore;

    allDevices = new ConcurrentHashMap<String, ConnectableDevice>(8, 0.75f, 2);
    compatibleDevices = new ConcurrentHashMap<String, ConnectableDevice>(8, 0.75f, 2);

    deviceClasses = new ConcurrentHashMap<String, Class<? extends DeviceService>>(4, 0.75f, 2);
    discoveryProviders = new CopyOnWriteArrayList<DiscoveryProvider>();

    discoveryListeners = new CopyOnWriteArrayList<DiscoveryManagerListener>();

    WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    multicastLock = wifiMgr.createMulticastLock(Util.T);
    multicastLock.setReferenceCounted(true);

    capabilityFilters = new ArrayList<CapabilityFilter>();
    pairingLevel = PairingLevel.OFF;

    receiver = new BroadcastReceiver() { 

        @Override 
        public void onReceive(Context context, Intent intent) { 
            String action = intent.getAction();

            if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
                NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);

                switch (networkInfo.getState()) {
                case CONNECTED:
                    if (mSearching) {
                        for (DiscoveryProvider provider : discoveryProviders) {
                            provider.restart();
                        }
                    }

                    break;

                case DISCONNECTED:
                    Log.w(Util.T, "Network connection is disconnected");

                    for (DiscoveryProvider provider : discoveryProviders) {
                        provider.reset();
                    }

                    allDevices.clear();

                    for (ConnectableDevice device: compatibleDevices.values()) {
                        handleDeviceLoss(device);
                    }
                    compatibleDevices.clear();

                    break;

                case CONNECTING:
                    break;
                case DISCONNECTING:
                    break;
                case SUSPENDED:
                    break;
                case UNKNOWN:
                    break;
                }
            }
        } 
    };

    registerBroadcastReceiver();
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:75,代码来源:DiscoveryManager.java

示例2: MyConnectableDeviceStore

import com.connectsdk.device.ConnectableDeviceStore; //导入依赖的package包/类
/**
 * Initilizes the Discovery manager with a valid context.  This should be done as soon as possible and it should use getApplicationContext() as the Discovery manager could persist longer than the current Activity.
 * 
 * This accepts a ConnectableDeviceStore to use instead of the default device store.
 * 
 @code
    MyConnectableDeviceStore myDeviceStore = new MyConnectableDeviceStore();
    DiscoveryManager.init(getApplicationContext(), myDeviceStore);
 @endcode
 */
public static synchronized void init(Context context, ConnectableDeviceStore connectableDeviceStore) {
    instance = new DiscoveryManager(context, connectableDeviceStore);
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:14,代码来源:DiscoveryManager.java

示例3: setConnectableDeviceStore

import com.connectsdk.device.ConnectableDeviceStore; //导入依赖的package包/类
/**
 * ConnectableDeviceStore object which loads & stores references to all discovered devices. Pairing codes/keys, SSL certificates, recent access times, etc are kept in the device store.
 *
 * ConnectableDeviceStore is a protocol which may be implemented as needed. A default implementation, DefaultConnectableDeviceStore, exists for convenience and will be used if no other device store is provided.
 *
 * In order to satisfy user privacy concerns, you should provide a UI element in your app which exposes the ConnectableDeviceStore removeAll method.
 *
 * To disable the ConnectableDeviceStore capabilities of Connect SDK, set this value to nil. This may be done at the time of instantiation with `DiscoveryManager.init(context, null);`.
 */
public void setConnectableDeviceStore(ConnectableDeviceStore connectableDeviceStore) {
    this.connectableDeviceStore = connectableDeviceStore;
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:13,代码来源:DiscoveryManager.java

示例4: getConnectableDeviceStore

import com.connectsdk.device.ConnectableDeviceStore; //导入依赖的package包/类
/**
 * ConnectableDeviceStore object which loads & stores references to all discovered devices. Pairing codes/keys, SSL certificates, recent access times, etc are kept in the device store.
 *
 * ConnectableDeviceStore is a protocol which may be implemented as needed. A default implementation, DefaultConnectableDeviceStore, exists for convenience and will be used if no other device store is provided.
 *
 * In order to satisfy user privacy concerns, you should provide a UI element in your app which exposes the ConnectableDeviceStore removeAll method.
 *
 * To disable the ConnectableDeviceStore capabilities of Connect SDK, set this value to nil. This may be done at the time of instantiation with `DiscoveryManager.init(context, null);`.
 */
public ConnectableDeviceStore getConnectableDeviceStore() {
    return connectableDeviceStore;
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:13,代码来源:DiscoveryManager.java


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