Developer’s Guide to Adding a .NET Barcode Library for Android

| Developers

Developer’s Guide to Adding a .NET Barcode Library for Android

An enterprise-grade .NET barcode scanner library for Android requires more than basic image capture and processing. Barcode scanning user experience (UX) is a small but essential component for keeping your app usable and useful for the business – and holds the key to improving adoption rates over the app’s lifetime.

This blog gives Android developers techniques to improve barcode scanning UX and performance leading to successful enterprise implementations. Later below, we provide a getting started tutorial for adding scanning features to Android applications using the Scandit .NET Barcode Scanner SDK.

“High product adoption rates aren’t just bragging rights; they signal an alignment between user needs and product design. Conversely, a low product adoption rate can serve as a distress signal, indicating fleeting engagements and unmet expectations.”
How Good Design Can Transform User Adoption Rates for SaaS Apps, UXPlanet

Why UX matters for Android barcode scanners

To avoid usability and performance issues, there are numerous UX techniques to consider.

For applications like barcode scanners, environmental conditions and varying levels of user skills can compromise the precision and accuracy necessary for effective captures. Assistance features, feedback, and scanning modes tailored for enterprise workflows lead to improved business results and happier employees.

Integrating the following UX workflows into your .NET barcode library for Android helps provide a better experience for your user base.

Starting the scanner

Employees have enough on their plates without worrying about navigating complex menus or waiting for a barcode scanner to start. A fast and seamless transition into scanning mode, no matter what the user is doing, helps users perform their jobs better.

The following video demonstrates how the Scandit .NET Barcode Scanner SDK allows users to quickly access the scanner and work successfully in a wide variety of scanning environments.

Assisting with aiming

Aiming an Android device’s camera can be difficult in environments where the barcode is hard to reach, or mixed in with other barcodes the user doesn’t want to scan. Two examples of UX elements that ease the selection of barcodes are:

  • A viewfinder to help users position the camera over barcodes correctly.
  • Restricting the scan area helps users focus on the correct barcode among a variety of barcodes. It also reduces the processing overhead on low-end devices.

Providing scanning feedback

Immediate and unambiguous feedback helps users know whether the barcode scan was successful or requires further action. A slow response or worse, a lack of feedback, leads to user confusion and frustration.

Techniques to help users understand the status of a scan are:

  • Playing audio and triggering haptic feedback when a barcode capture is successful.
  • Drawing a brush overlay at the screen position of the detected barcode, confirming that the intended item was scanned by the app.

Allowing single and multiple barcode scans

Switching between scanning single and multiple barcodes helps users tailor their workflows to their tasks and environment.

If the number or configuration of barcodes varies, such as in a warehouse or retail store, allowing users to scan multiple barcodes at a time decreases their workload. If they only need to scan a single barcode within range of other barcodes, supporting single scans lets them find and confirm the right one to capture.

The differences between these modes are:

  • Single scan: The user triggers the scanner for every barcode, providing greater control over the scanning experience.
  • Continuous scan: The user triggers the scanner once and the app scans multiple barcodes without further interaction, reducing user fatigue.

SCAN FAST AND ACCURATELY

Test the Scandit barcode scanning SDK for .NET

Try for Free

Key development considerations for .NET barcode libraries for Android

Here are other considerations to think about when building your barcode scanner for .NET Android apps.

1. Performance

Different Android device models and OS versions have different impacts on the performance of your barcode scanner. Consider the following requirements for your app and test cases:

  • Accuracy: Barcode scanning for high-volume enterprise workflows, such as inventory management, asset tracking, and last-mile delivery, requires captures with few or no errors. Even a 95% success rate is unlikely to be good enough, so aim for 99% or greater success rates.
  • Speed: A barcode scanner that captures and processes barcodes fast means accelerated business operations.
  • Field-of-view and distance: Scanners must be capable of reading barcodes on items of various sizes and shapes and at various distances from the camera.
  • Scanning barcodes in degraded conditions: Your solution should account for barcodes that are torn, obscured, crumpled, or wrapped in plastic.
  • Start-up time: To avoid slowing down users, your barcode scanner should support a “standby mode” that minimizes camera start-up delays between scans.
  • Capturing multiple barcodes fast: Workers in fulfillment centers or back-of-store retail operations usually scan multiple barcodes at once or in quick succession.

2. Low-light conditions

Lighting conditions in the real world vary widely, from daytime delivery operations to nighttime vehicle offloading. Your .NET barcode library for Android should maintain speed and accuracy under all conditions, otherwise users will opt out of using it.

3. Large device fleets with diverse models

Enterprises often have a diverse fleet of employee devices with different camera specifications and platform architectures – especially in Bring-Your-Own-Device (BYOD) situations.

Your barcode scanner must be architected and designed to perform on Android platforms ranging from the latest smartphone model to legacy hardware. To measure how well your solution performs, we list key performance tests at the end of this blog.

A barcode scanner library should be optimized for processor performance and resource loading, and make efficient use of background tasks. The Scandit .NET Barcode Scanner SDK, for example, is built on a C/C++ foundation, ensuring that core barcode scanning features are loaded efficiently in the background and consume minimal system resources.

4. Support for different development frameworks

You may need to provide support for different platforms and frameworks for developers working in different environments. Scandit’s barcode scanning products are available for Native iOS, Native Android, Cordova, Xamarin (iOS, Android, and Forms), .NET iOS, React Native, JavaScript, Flutter, Capacitor, and Titanium.

5. Open-source .NET barcode scanner libraries

Many .NET developers choose open-source Android libraries for their ease of access and cost-effectiveness, thinking they only need basic features. For barcode scanners, there’s a tradeoff between the benefits of open source and the speed, accuracy, and support necessary for enterprise operations.

If you’re supporting a business-critical environment like a warehouse, retail stockroom, or last-mile delivery, an open-source .NET Android barcode library may not be the best choice. High-performance, accurate, and built to operate under difficult situations, commercial barcode scanner SDKs are often better suited for demanding enterprise use cases.

Fast, accurate, and reliable scanning with the Scandit .NET Barcode Scanner SDK

The Scandit .NET Barcode Scanner SDK, part of the Scandit Smart Data Capture Platform, allows developers to integrate a high-performance .NET barcode library into Android applications. This Scandit SDK gives you enterprise-proven features that are extensible to support your own capabilities.

The next sections explain how to implement a customizable Android-based barcode scanning interface in just a few steps with the Scandit .NET Barcode Scanner SDK.

BARCODE SCANNING IN .NET MADE EASY

Integration is easy with ready-to-use UI components.

Free 30-day SDK Trial

Get started with the Scandit .NET Barcode Scanner SDK

Follow these steps to add the pre-built SDK features to your app for single barcode scanning. You can also test the Scandit SDK using our .NET for Android code samples on GitHub.

The prerequisites for these steps are:

  • The latest stable version of Visual Studio.
  • A .NET SDK.
  • A .NET for Android project with target SDK version 23 (Android 6, Marshmallow) or higher.
  • A valid Scandit Data Capture SDK license key. You can sign up for a free test account at ssl.scandit.com.

Although not covered here, the Scandit .NET Barcode Scanner SDK also supports scanning multiple barcodes at once (batch scanning). The instructions for setting up and using this capability are located in our Get Started With MatrixScan documentation.

1. Add the SDK

The Scandit Data Capture SDK is distributed as NuGet packages, which you get from the NuGet site.

You must add the Scandit.DataCapture.Core and Scandit.DataCapture.Barcode (the ScanditBarcodeCapture API) packages, which contain the functionality for barcode scanning. When developing a MAUI application, you also need to add the Scandit.DataCapture.Core.Maui package.

You must also consider:

  • The Scandit SDK uses content providers to initialize the scanning capabilities properly. If your own content providers depend on the Scandit SDK, choose an initOrder lower than 10 to make sure the SDK is ready first. If not specified, initOrder is zero by default and you have nothing to worry about. For more details, check the official Android <provider> documentation.
  • Camera permissions: When using the Scandit Data Capture SDK, you must set the camera as the frame source for various capture modes. On .NET for Android or MAUI, you must request camera permissions in your application before starting scanning. To see how to do this, take a look at our samples.
  • When using the Scandit Data Capture SDK in a MAUI application, you have to request camera permissions in your own application before starting scanning. To see how you can achieve this, take a look at our samples for Android or MAUI.

2. Create the data capture context

To add capture capabilities to your application, you must create a new data capture context, which expects a valid Scandit Data Capture SDK license key during construction:

DataCaptureContext context = DataCaptureContext.ForLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");

3. Configure the barcode scanning behavior

Barcode scanning is orchestrated by the BarcodeCapture data capture mode. This class is the main entry point for scanning barcodes. It is configured through BarcodeCaptureSettings and registers one or more listeners that are informed whenever new codes are recognized.

For this blog, we set up barcode scanning for a small list of symbologies. Change this to the correct symbologies for your use case.

BarcodeCaptureSettings settings = BarcodeCaptureSettings.Create();
HashSet<Symbology> symbologies = new HashSet<Symbology>()
{
    Symbology.Code128,
    Symbology.Code39,
    Symbology.Qr,
    Symbology.Ean8,
    Symbology.Upce,
    Symbology.Ean13Upca
};
settings.EnableSymbologies(symbologies);

If you are not disabling barcode capture immediately after scanning the first code and do not want the same code to be scanned more than once, consider setting the BarcodeCaptureSettings.codeDuplicateFilter to around 500 or even -1.

Next, create a BarcodeCapture instance with the settings initialized in the previous step:

barcodeCapture = BarcodeCapture.Create(context, settings);

4. Register the barcode capture listener to be informed when a new barcode is scanned

To get informed whenever a new code has been recognized, add an IBarcodeCaptureListener through BarcodeCapture.addListener() and implement the listener methods to suit your application’s needs.

Implement the IBarcodeCaptureListener interface:

public void OnBarcodeScanned(BarcodeCapture barcodeCapture, BarcodeCaptureSession session, IFrameData frameData)
{
IList barcodes = session?.NewlyRecognizedBarcodes;
// Do something with the barcodes
}

Add the listener:

barcodeCapture.AddListener(this);

Alternatively, to register the IBarcodeCaptureListener interface, it is possible to subscribe to corresponding events. For example:

barcodeCapture.BarcodeScanned += (object sender, BarcodeCaptureEventArgs args) =>
{
IList barcodes = args.Session?.NewlyRecognizedBarcodes;
// Do something with the barcodes
}

5. Use the built-in camera

The data capture context supports different frame sources to perform recognition. Most Android applications use the built-in camera of the device, such as the rear camera. This blog assumes you are using the built-in camera.

On Android, the user must explicitly grant permission for each app to access cameras. Your app must declare the use of the Camera permission in the AndroidManifest.xml file and request it at runtime so the user can grant or deny the permission. To do that follow the Android guidelines to request the android.permission.CAMERA permission.

The built-in camera has recommended settings for each capture mode. These should be used to achieve the best performance and user experience for the respective mode. The following code shows how to get the recommended settings and create the camera from it:

camera = Camera.GetDefaultCamera();
camera?.ApplySettingsAsync(BarcodeCapture.RecommendedCameraSettings);

As the frame source is configurable, the data capture context must be told which frame source to use via a call to DataCaptureContext.setFrameSourceAsync():

context.SetFrameSourceAsync(camera);

The camera is off by default and must be turned on by calling IFrameSource.SwitchToDesiredStateAsync() with a value of FrameSourceState.On:

camera?.SwitchToDesiredStateAsync(FrameSourceState.On);

6. Use a Capture View to visualize the scan process

When using the built-in camera as the frame source, it helps the user to display the camera preview on the screen with UI elements that guide the capture process.

To do this, add a DataCaptureView to your view hierarchy:

DataCaptureView dataCaptureView = DataCaptureView.Create(this, dataCaptureContext);
SetContentView(dataCaptureView);

Alternatively, you can use a DataCaptureView from XAML in your MAUI application. For example:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:scandit="clr-namespace:Scandit.DataCapture.Core.UI.Maui;assembly=ScanditCaptureCoreMaui"
  <ContentPage.Content>
      <AbsoluteLayout>
          <scandit:DataCaptureView
              x:Name="dataCaptureView"
              AbsoluteLayout.LayoutBounds="0,0,1,1"
              AbsoluteLayout.LayoutFlags="All"
              DataCaptureContext="{Binding DataCaptureContext}" >
          </scandit:DataCaptureView>
      </AbsoluteLayout>
  </ContentPage.Content>
</ContentPage>

You can configure your view in the code behind class. For example:

public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();

// Initialization of DataCaptureView happens on handler changed event.
dataCaptureView.HandlerChanged += DataCaptureViewHandlerChanged;
}

private void DataCaptureViewHandlerChanged(object? sender, EventArgs e)
{
// Your dataCaptureView configuration goes here, e.g. add overlay
}
}

To visualize the results of barcode scanning, add the following overlay:

BarcodeCaptureOverlay overlay = 
BarcodeCaptureOverlay.Create(barcodeCapture, dataCaptureView);

7. Disable barcode capture

To disable barcode capture, such as when a barcode is recognized, set BarcodeCapture.Enabled to false. This stops all processing of frames after the change, but the camera continues to stream frames until it is turned off. If a frame is in the middle of processing, it is completely processed and delivers any results/callbacks to the registered listeners.

Testing barcode scanning performance

Running your .NET barcode library for Android under real user scenarios and environments is the ideal way to test user experience and performance. Whether using the Scandit .NET Barcode Scanner SDK or another .NET barcode scanning library, here are several performance-testing questions to ask:

  • Is there clear guidance and feedback to foster smooth workflows rather than confuse scanning tasks?
  • Can you scan barcodes at a distance? Are you able to zoom in if needed?
  • Can you scan barcodes in different orientations, such as upside down and sideways? Flip the device upside down to see how the scanner performs.
  • Can you scan barcodes with reflections and glare?
  • Do you receive scanning feedback in loud environments and while wearing headphones?

You can also use our barcodes sample sheet to evaluate your .NET barcode scanner library quickly.

Get the Scandit .NET Barcode Scanner SDK for Android now

Brilliant UX and performance comes from implementing the right .NET barcode scanner API for Android. User adoption rates and happiness improve by making barcode scanning easy to use, highly performant, and adaptable to growing business demands.

Interested in how the Scandit .NET Barcode Scanner SDK adds intuitive, high-performance scanning to Android apps with minimal frustration? Sign up for our free 30-day test SDK now.