Fixing Common 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
alert("Socket Mobile Companion must be installed to use your scanner") {
    positiveButton("Install") { // onClick
        Capture.installCompanion(context)
    }
}

Companion not upgraded

The Socket Mobile Companion is not upgraded to the latest version in play store.

Error code

CaptureError.COMPANION_NOT_UPGRADED

Suggested fix

Prompt the user to install the latest 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
alert("Socket Mobile Companion must be upgraded to use your scanner") {
    positiveButton("Install") { // onClick
        Capture.installCompanion(context)
    }
}

Service not running

The Companion 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
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));
    }
}