Class Connectivity

java.lang.Object
com.vuzix.connectivity.sdk.Connectivity

public class Connectivity extends Object
The Connectivity class is the main entry point into the Connectivity SDK.
  • Field Details

  • Method Details

    • get

      public static Connectivity get(android.content.Context context)
      Returns the global Connectivity object associated with your application.
      Parameters:
      context - a Context
      Returns:
      a Connectivity object
    • addDeviceListener

      public void addDeviceListener(Connectivity.DeviceListener listener)
      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

      public void removeDeviceListener(Connectivity.DeviceListener listener)
      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

      public List<Device> getDevices()
      Returns a list of all available remote devices that are linked to this device.
      Returns:
      a List of Device objects
    • getDevice

      public Device getDevice(long id)
      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

      public Device 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

      public boolean isConnected(Device device)
      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

      public boolean sendBroadcast(Device device, android.content.Intent intent)
      Sends a broadcast to the specified remote device.
      Parameters:
      device - the Device to send the broadcast to
      intent - 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 to
      intent - the Intent to send as a broadcast
      Returns:
      a SynchronousOrderedBroadcastResult or null if the underlying sendOrderedBroadcast fails
      Throws:
      InterruptedException - if interrupted
    • sendOrderedBroadcast

      public boolean sendOrderedBroadcast(Device device, android.content.Intent intent)
      Sends an ordered broadcast to the specified remote device.
      Parameters:
      device - the Device to send the broadcast to
      intent - 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 to
      intent - the Intent to send as a broadcast
      resultReceiver - 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 to
      intent - the Intent to send as a broadcast
      resultReceiver - the BroadcastReceiver where the ordered broadcast result should be delivered
      initialCode - an initial value for the result code, often Activity.RESULT_OK
      initialData - an initial value for the result data, often null
      initialExtras - an initial value for the result extras, often null
      Returns:
      true if the broadcast was successfully sent, false otherwise
    • getSendingDevice

      public Device getSendingDevice(android.content.Intent intent)
      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

      public static String getSendingPackage(android.content.Intent intent)
      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

      public boolean verify(android.content.Intent intent, String _package)
      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