Fixing Common Connection Errors

Companion not installed

The Socket Mobile Companion does not appear to be installed.

Error code
CaptureError.COMPANION_NOT_INSTALLED
Suggested fix
Prompt the user to install Socket Mobile Companion. Once you have obtained consent, you can use Capture.installCompanion(Context) to open the Play store.
// Example in Kotlin and using Anko DSL for brevity
alert("Socket Mobile Companion must be installed to use your scanner") {
    positiveButton("Install") { // onClick
        Capture.installCompanion(context)
    }
}

Service not running

The Capture service is not running. When using the non-Android client, this may indicate that the Socket Mobile Companion has not been installed or the service has not been started. If using the Android client, this most likely indicates that the service has crashed.

Error code
CaptureError.SERVICE_NOT_RUNNING
Suggested fix
If the client is still disconnecting, do nothing. Once it is disconnected, start/restart the service.
if (state.isDisconnected()) {
    if (Capture.notRestartedRecently()) {
        Capture.restart(this);
    } else {
        // Service keeps crashing - Reboot the host device and check for updates to Companion
    }
}

Bluetooth not enabled

Bluetooth is off

Error code
CaptureError.BLUETOOTH_NOT_ENABLED
Suggested fix
Prompt the user to enable Bluetooth
// Example in Kotlin and using Anko DSL for brevity
alert("Bluetooth must be enabled to use your scanner") {
    positiveButton("Enable") { // onClick
        // BLUETOOTH permission must be enabled in your AndroidManifest
        startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE));
    }
}