.. title:: Next Steps on Android Next Steps ========== Your app can only receive data from the scanner if your app and the scanner are both connected to the service and your app has ownership of the scanner. All Socket Mobile scanners have an LED which displays the connection status of the scanner to the service, but your app is responsible for displaying the status of *its* connection to both the service and the scanner to the user. Scanner Status -------------- To receive device availability events, add a ``@Subscribe`` annotated method that takes a :java:ref:`DeviceStateEvent` as an argument to any ``Activity`` and it will be called when a scanner becomes available or unavailable. .. code-block:: java @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) public void onCaptureDeviceStateChange(DeviceStateEvent event) { DeviceClient device = event.getDevice(); DeviceState state = event.getState(); switch(state.intValue()) { case DeviceState.READY: // Ready to use break; default: // Device not ready for use } } .. note:: You should not need to store the current state of the device if you subscribe to the event with ``sticky = true``. When an activity is destroyed and recreated, it will receive the last event containing the current state of the device. Service Status -------------- Add an ``@Subscribe`` annotated method that takes a :java:ref:`ConnectionStateEvent` as an argument to any ``Activity`` to be notified of changes to the state of the connection to the service. .. code-block:: java @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) public void onCaptureServiceConnectionStateChange(ConnectionStateEvent event) { ConnectionState state = event.getState(); CaptureClient client = event.getClient(); if (state.hasError()) { CaptureError error = state.getError(); switch(error.getCode()) { // ... } } switch(state.intValue()) { case ConnectionState.CONNECTING: // ... break; case ConnectionState.CONNECTED: // ... break; case ConnectionState.READY: // ... break; case ConnectionState.DISCONNECTING: // ... break; case ConnectionState.DISCONNECTED: // ... break; } }