Package com.vuzix.connectivity.sdk
Class Connectivity
java.lang.Object
com.vuzix.connectivity.sdk.Connectivity
The Connectivity class is the main entry point into the Connectivity SDK.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDeviceListeners are interested in all events that could happen with Connectivity.static classConvenience class for implementing a DeviceListener without having to implement all methods.static classA simple data-struct to pass the results of a synchronous ordered broadcast around -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeviceListener(Connectivity.DeviceListener listener) Adds a DeviceListener which will be notified when Connectivity events happen.static Connectivityget(android.content.Context context) Returns the global Connectivity object associated with your application.Convenience method for obtaining a remote device.getDevice(long id) Returns a device with the specified id.Returns a list of all available remote devices that are linked to this device.getSendingDevice(android.content.Intent intent) Determines the remote device that sent the given intent.static longgetSendingDeviceId(android.content.Intent intent) Extracts the device id from an intent.static StringgetSendingPackage(android.content.Intent intent) Determines the remote package (app) that sent the intent.booleanDetermines if Connectivity is available on this device.booleanDetermines if any remote devices are currently connected.booleanisConnected(Device device) Determines if the specified device is currently connected.booleanisLinked()Determines if any remote devices are linked.voidRemoves a DeviceListener.booleansendBroadcast(android.content.Intent intent) Sends a broadcast to all connected remote devices.booleansendBroadcast(Device device, android.content.Intent intent) Sends a broadcast to the specified remote device.booleansendOrderedBroadcast(Device device, android.content.Intent intent) Sends an ordered broadcast to the specified remote device.booleansendOrderedBroadcast(Device device, android.content.Intent intent, BroadcastResultReceiver resultReceiver) Sends an ordered broadcast to the specified remote device.booleansendOrderedBroadcast(Device device, android.content.Intent intent, BroadcastResultReceiver resultReceiver, int initialCode, String initialData, android.os.Bundle initialExtras) Sends an ordered broadcast to the specified remote device.sendSynchronousOrderedBroadcast(Device device, android.content.Intent intent) Synchronously send an ordered broadcast message to a remote device.booleanverify(android.content.Intent intent) Determines if the given intent is a valid intent that came from the Connectivity framework.booleanDetermines if the given intent is a valid intent that came from the Connectivity framework and that it originated from the specified package.
-
Field Details
-
ACTION_DEVICE_ADDED
- See Also:
-
ACTION_DEVICE_CHANGED
- See Also:
-
ACTION_DEVICE_REMOVED
- See Also:
-
ACTION_DEVICE_CONNECTED
- See Also:
-
ACTION_DEVICE_DISCONNECTED
- See Also:
-
ACTION_ORDERED_BROADCAST_RESULT
- See Also:
-
EXTRA_DEVICE_ID
- See Also:
-
EXTRA_SENDING_PACKAGE
- See Also:
-
EXTRA_VERIFY_DATA
- See Also:
-
EXTRA_VERIFY_SIGNATURE
- See Also:
-
EXTRA_BROADCAST_ID
- See Also:
-
EXTRA_BROADCAST_RESULT_CODE
- See Also:
-
EXTRA_BROADCAST_RESULT_DATA
- See Also:
-
EXTRA_BROADCAST_RESULT_EXTRAS
- See Also:
-
-
Method Details
-
get
Returns the global Connectivity object associated with your application.- Parameters:
context- a Context- Returns:
- a Connectivity object
-
addDeviceListener
Adds a DeviceListener which will be notified when Connectivity events happen. Be sure to call removeDeviceListener(DeviceListener) when your listener is no longer needed.- Parameters:
listener- the DeviceListener to add
-
removeDeviceListener
Removes a DeviceListener.- Parameters:
listener- the DeviceListener to remove
-
isAvailable
public boolean isAvailable()Determines if Connectivity is available on this device. If Connectivity is not available, no further calls should be made on this class.- Returns:
- true if Connectivity is available, false otherwise
-
getDevices
Returns a list of all available remote devices that are linked to this device.- Returns:
- a List of Device objects
-
getDevice
Returns a device with the specified id.- Parameters:
id- the id of a Device- Returns:
- a Device object or null if the device id was not found
-
getDevice
Convenience method for obtaining a remote device. This method should only be used if it is expected that only one remote device could be linked.- Returns:
- a Device object or null if there are no remote devices
-
isLinked
public boolean isLinked()Determines if any remote devices are linked.- Returns:
- true if this device has any linked remote devices, false otherwise
-
isConnected
public boolean isConnected()Determines if any remote devices are currently connected.- Returns:
- true if any remote devices are currently connected, false otherwise
-
isConnected
Determines if the specified device is currently connected.- Parameters:
device- a Device- Returns:
- true if the device is connected, false otherwise
-
sendBroadcast
public boolean sendBroadcast(android.content.Intent intent) Sends a broadcast to all connected remote devices.- Parameters:
intent- the Intent to send as a broadcast- Returns:
- true if the broadcast was successfully sent, false otherwise
-
sendBroadcast
Sends a broadcast to the specified remote device.- Parameters:
device- the Device to send the broadcast tointent- the Intent to send as a broadcast- Returns:
- true if the broadcast was successfully sent, false otherwise
-
sendSynchronousOrderedBroadcast
public Connectivity.SynchronousOrderedBroadcastResult sendSynchronousOrderedBroadcast(Device device, android.content.Intent intent) throws InterruptedException Synchronously send an ordered broadcast message to a remote device.NOTE: DO NOT CALL FROM MAIN THREAD!
- Parameters:
device- the Device to send request tointent- the Intent to send as a broadcast- Returns:
- a SynchronousOrderedBroadcastResult or null if the underlying sendOrderedBroadcast fails
- Throws:
InterruptedException- if interrupted
-
sendOrderedBroadcast
Sends an ordered broadcast to the specified remote device.- Parameters:
device- the Device to send the broadcast tointent- the Intent to send as a broadcast- Returns:
- true if the broadcast was successfully sent, false otherwise
-
sendOrderedBroadcast
public boolean sendOrderedBroadcast(Device device, android.content.Intent intent, BroadcastResultReceiver resultReceiver) Sends an ordered broadcast to the specified remote device.- Parameters:
device- the Device to send the broadcast tointent- the Intent to send as a broadcastresultReceiver- the BroadcastReceiver where the ordered broadcast result should be delivered- Returns:
- true if the broadcast was successfully sent, false otherwise
-
sendOrderedBroadcast
public boolean sendOrderedBroadcast(Device device, android.content.Intent intent, BroadcastResultReceiver resultReceiver, int initialCode, String initialData, android.os.Bundle initialExtras) Sends an ordered broadcast to the specified remote device.- Parameters:
device- the Device to send the broadcast tointent- the Intent to send as a broadcastresultReceiver- the BroadcastReceiver where the ordered broadcast result should be deliveredinitialCode- an initial value for the result code, often Activity.RESULT_OKinitialData- an initial value for the result data, often nullinitialExtras- an initial value for the result extras, often null- Returns:
- true if the broadcast was successfully sent, false otherwise
-
getSendingDevice
Determines the remote device that sent the given intent.- Parameters:
intent- an Intent- Returns:
- the Device that send the intent or null if the sender could not be determined
-
getSendingDeviceId
public static long getSendingDeviceId(android.content.Intent intent) Extracts the device id from an intent.- Parameters:
intent- an Intent- Returns:
- the device id that send the intent or null if the device id could not be determined
-
getSendingPackage
Determines the remote package (app) that sent the intent.- Parameters:
intent- an Intent- Returns:
- the remote package name or null if the remote package could not be determined
-
verify
public boolean verify(android.content.Intent intent) Determines if the given intent is a valid intent that came from the Connectivity framework. Use this method to verify an intent was not spoofed locally by another app.- Parameters:
intent- an Intent- Returns:
- true if the intent came through Connectivity, false otherwise
-
verify
Determines if the given intent is a valid intent that came from the Connectivity framework and that it originated from the specified package. Use this method to verify an intent was not spoofed locally by another app.- Parameters:
intent- an Intent_package- the package name to verify- Returns:
- true if the intent came through Connectivity from the specified package, false otherwise
-