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