Getting Started - Android

Try a sample app. For Xamarin: Capture Xamarin SDK Sample, for Maui: Capture Maui SDK Sample.

Requirements

SocketMobile Companion app is required for the SDK to work. Click here to download it from the Google Play Store.

An application using the Socket CaptureSDK needs to be registered in order to retrieve an AppKey that is required by the Capture API. You can register for an app key on the here. Note you will have to log in to create an App Key.

SDK Installation

The SDK is released as a NuGet package named SocketMobile.Capture. The NuGet package lies in the public NuGet Manager.

The CaptureSDK NuGet depends on JSON NuGet from Newtonsoft that will get installed as well.

Configure and Pair Socket Mobile Devices

The scanner can be configured and paired with Add A Reader using Socket Mobile Companion app. Below adds more details to the setup.

Configuring the Scanner

By default, the factory settings of the Socket Cordless Scanners are set to Basic Mode (keyboard emulation: HID). In order to use the scanner with an application using CaptureSDK, the scanner must be configured in Application Mode (Bluetooth Serial Port Profile: SPP).

The following barcode will configure your scanner into Application Mode:

_images/spp1d.png

Note

This configuration barcode is persistent across power cycling the scanner and needs to be scanned only once. The scanner will stay in that mode until it is reset to its factory defaults, or until the keyboard emulation Basic Mode(HID) barcode is scanned.

Connecting/Pairing the Scanner to the Host

The process of doing the initial pairing of the scanner to a host Android is very simple. Make sure that there is no previous pairing saved in the host and in the scanner. On the scanner the pairing can be cleared by following these steps:

  • Turn on the scanner

  • Press the power button while pressing the scan button

  • wait for the scanner to turn off

A series of 3 beeps will confirm the pairing information has been deleted. If these 3 beeps are not heard, retry these steps until you hear the 3 beeps.

To connect the scanner to the host, turn it on and either scan a command barcode that contains the Host Bluetooth Address or simply go to the host Bluetooth settings, discover the scanner and pair to it.

Note

Make sure the Socket Mobile Companion software is running at that time and the scanner should automatically connect to Socket Mobile Companion software. A beep confirms when the scanner is connected and ready to be used.

Add package name

Use the same pacakge name that was previously used to register the application.

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="..."  package="<YOUR_PACKAGE_NAME_HERE>">
</manifest>

Add credentials

Add your credentials in the AndroidManifest.xml inside <application></application>.

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="...">
  <application android:label="...">
    <meta-data android:name="com.socketmobile.capture.APP_KEY" android:value="<YOUR_APP_KEY>" />
    <meta-data android:name="com.socketmobile.capture.DEVELOPER_ID" android:value="<YOUR_DEVELOPER_ID>" />
  </application>
</manifest>

Targeting Android 28+?

Apps that target Android 28+ must also enable cleartext traffic to localhost. If you do not already have a network security configuration file, you will need to create one.

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="..." >
  <application android:label="..."
      android:networkSecurityConfig="@xml/network_security_config"
      ...>

  </application>
</manifest>
res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <base-config cleartextTrafficPermitted="false" />
  <domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="false">localhost</domain>
    <domain includeSubdomains="false">127.0.0.1</domain>
  </domain-config>
</network-security-config>