Ask Your Question
4

How can the Zebra DataWedge API be utilized with Flutter and android_intent_plus?

asked 2021-07-16 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-01-08 12:00:00 +0000

lalupa gravatar image
  1. Adding the DataWedge API to the Android Project:

    • Create a new Android module in your Flutter project by running flutter create --template=module datawedge_api.
    • Include the DataWedge API in your module by downloading the DataWedge Manager and DataWedge API libraries from the Zebra Support website.
    • Add the libraries to your module by copying the Android libraries (.jar files) to the libs folder of your module and the Native libraries (.so files) to the jniLibs folder.
    • Declare the DataWedge API package in your module's AndroidManifest.xml file.
  2. Setting Up the Intent Filter:

    • Define an intent filter for your app in the AndroidManifest.xml file with the action com.symbol.datawedge.api.ACTION_RESULT.
    • Add a category to the intent filter to match the DataWedge profile name.
  3. Configuring the DataWedge Profile:

    • Create a custom DataWedge profile for your app by opening the DataWedge Manager and selecting "Create profile".
    • Configure the profile to map the barcode data to an Intent and set the Intent package to your app's package name.
    • Activate the profile.
  4. Implementing the DataWedge API:

    • Import the android_intent_plus package and the com.symbol.datawedge.api package in your Dart file.
    • Call the sendIntentWithExtras method from the android_intent_plus package to launch the barcode reading activity.
    • In the OnActivityResult method, parse the data from the barcode result intent and perform the required action.
    • Use the DataWedge API to communicate with the DataWedge service and configure the profile as required.

Example Code:

import 'package:android_intent_plus/android_intent.dart';
import 'package:com.symbol.datawedge.api.datawedge.dart';

final _barcodeControl = new DataWedgeIntentControl();
final _scanReceiver = new ScanBroadcastReceiver();

// Set up DataWedge profile
await _barcodeControl.createProfile(
      profileName: 'MyProfile',
      profileEnabled: true,
      intentAction: 'com.mycompany.myapp.ACTION',
      intentCategory: 'android.intent.category.DEFAULT',
      intentOutputEnabled: true,
);

// Launch barcode scanner
final intentScan = AndroidIntent(
  action: 'com.symbol.datawedge.api.ACTION',
  category: 'android.intent.category.DEFAULT',
  package: 'com.symbol.datawedge.api',
  extras: {'com.symbol.datawedge.api.REQUEST_ACTION': 'START_SCANNING'},
);
await intentScan.launch();

// Handle barcode scan result
_scanReceiver.stream.listen((barcodeData) {
  // Parse the barcode data from intent extras
  final data = barcodeData['com.symbol.datawedge.data_string'].toString();

  // Perform action with barcode data
});

// Clean up DataWedge profile
await _barcodeControl.removeProfile(profileName: 'MyProfile');
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-07-16 11:00:00 +0000

Seen: 9 times

Last updated: Jan 08 '22