Skip navigation

Android Blogs

7 Posts authored by: Robert Galvin

Recently Google released Android Studio 3.0 to it's "Canary & Dev stable channel"and comes with some really awesome features as discussed in this blog post, but before you fired up your EMDK for Android environment and start using it, you will want to follow the directions below for getting your EMDK dev environment setup correctly.


Step 1: Install EMDK 6.6

There are no special instructions on running the EMDK Installer, so go ahead and download it from our support portal and follow the setup instructions found on Techdocs.


Step 2: Download Android Studio 3.0

Head on over to and follow Google's instructions for install and setup of Android Studio 3.0 Preview


Step 3: Get the Android SDK Folder

First, get the Android SDK folder being used by looking at: Android Studio >> File >> Settings >> Appearance & Behavior >> System settings >> Android SDK


Then, after you noted down the SDK folder, close Android Studio.


Step 4: Copy SDK Add-Ons

From EMDK installed folder (eg: C:\Program Files (x86)\Symbol EMDK for Android\v6.6\Integrator\add-ons), copy all add-ons to Android SDK add-ons folder (eg: C:\Users\<Your user name>\AppData\Local\Android\Sdk\Add-ons).



Step 5: Copy Plug-ins

From EMDK installed folder (Eg: C:\Program Files (x86)\Symbol EMDK for Android\v6.3\Integrator\plugins\IntelliJ IDEA), copy “com.symbol.emdk.wizard.intellijIdea” folder to Android Studio installed folder (eg: C:\Beta releases\android-studio preview\plugins).


That's it! - Fire up Android Studio and you should be all set.

The current version of EMDK For Android 6.x will not work if you have upgraded to the latest Android Studio release 2.3. You may not have noticed this unless you tried to use Profile Manager from the EMDK menu. While we plan on incorporating this into the next official release, we felt it was important to put out an immediate beta release patch to address this now prior to the official release.


PC Installation

1. Install or upgrade the Android Studio v2.3

2. Exit the Android Studio if it is running

3. Install EMDK for Android 6.x. Refer the installation instructions for more details. Remember the EMDK Installation location for later use.

4. Download the attached to this post

5. Unzip and copy the com.symbol.emdk.wizard.core.jar & com.symbol.emdk.wizard.intellijIdea.jar to EMDK Installed location i.e., C:\Program Files (x86)\Symbol EMDK for Android\v6.0\Integrator\plugins\IntelliJ IDEA\com.symbol.emdk.wizard.intellijIdea\lib\

6. Run the EMDK Integrator from Start Menu as shown below.

Screen Shot 2017-03-15 at 11.04.20 AM.jpg


7. Restart the Android Studio for your development.


Mac Installation

1. Install or upgrade to Android Studio v2.3

2. Exit Android Studio if it is running

3. Re-Install EMDK for Android 6.x. Refer the installation instructions for more details.

4. Download the attached to this post.

5. Launch Finder on MAC and go to the Applications folder.

6. Locate Android Studio App, right click and select Show Package Contents.

7. Locate the Contents\plugins\com.symbol.emdk.wizard.intellijIdea\lib directory

8. Unzip and copy the com.symbol.emdk.wizard.core.jar & com.symbol.emdk.wizard.intellijIdea.jar  files into Contents\plugins\com.symbol.emdk.wizard.intellijIdea\lib directory

9. Restart the Android Studio for your development.

The latest EMDK For Android - version 6.0 has been released and is now available for download. In this release there has been several new devices supported, features added, samples updated and many bug fixes.



Here is a brief summary of what is new in this release. The full online documentation can be found at:



  1. Added support for ET50, ET55 and TC8000 Lollipop (Android 5.1.1) devices.
  2. Added support for MX v6.1 in Profile Manager:
    • Threat Manager – Added new feature to configure the detection of rooting and to apply a countermeasure when the device is detected as being rooted.
    • UI Manager – Added new feature to allow or disallow network monitored messages/notifications.
    • Bluetooth Manager – Added new feature to enable or disable the mobile device discoverability.
    • GPRS Manager – Added new capability to add APN and set certain parameters such as proxy, server, port.
    • Wi-Fi – Added new feature to enable or disable the password protected encryption.
    • Device Administrator – Added new feature to select the type of screen lock such as no password, password, pattern and swipe.
    • Wireless Manager – Added new feature to specify balance between accuracy and battery life when using GPS.
    • KeyMapping Manager – Added key mapping support for Rear Button and Grip Trigger 2.
  3. Enhanced Barcode Manager APIs with the following features:
    • Added new decoder parameter in Code128, Code39, I2of5 and UpcEan decoders in ScannerConfig.DecoderParams:
      • reducedQuietZone - Flag to enable or disable the decoding of margin less barcodes.
    • Added new parameter to ScannerConfig.DecoderParams.Gs1DatabarLim:
      • securityLevel - Sets the four levels of decode security for GS1 Databar Lim barcodes.
    • Added new reader parameters in ScannerConfig.ReaderParams.ReaderSpecific.ImagerSpecific:
      • oneDQuietZoneLevel - This parameter sets the effort at which the decoder will attempt to decode margin-less barcodes.
      • poorQualityDecodeEffortLevel - This parameter permits selection of enhancement modes for decoding barcodes of poor or degraded quality.
      • Added new reader parameters in ScannerConfig.ReaderParams.ReaderSpecific. CameraSpecific:
      • viewfinderSize - Sets the View Finder window size in camera scanner as a percentage of full width and full height.
      • viewfinderOffsetX - Sets the X axis position of the top left corner of the view finder.
      • viewfinderOffsetY - Sets the Y axis position of the top left corner of the view finder.
      • oneDQuietZoneLevel - This parameter sets the effort at which the decoder will attempt to decode margin-less barcodes.
      • poorQualityDecodeEffortLevel - This parameter permits selection of enhancement modes for decoding barcodes of poor or degraded quality.
    • Added new reader parameters in ScannerConfig.ReaderParams.ReaderSpecific.LaserSpecific:
      • adaptiveScanning - This parameter enables or disables the adaptive scanning.
      • beamWidth - Controls the beam width of the laser scanner. Laser beam width can be shortened or widened using this parameter.
      • oneDQuietZoneLevel - This parameter sets the effort at which the decoder will attempt to decode margin-less barcodes.
      • poorQualityDecodeEffortLevel - This parameter permits selection of enhancement modes for decoding barcodes of poor or degraded quality.
    • Added new enums in ScannerConfig:
      • OneDQuietZoneLevel - Describes the effort at which the decoder will attempt to decode margin-less barcodes.
      • PoorQualityDecodeEffortLevel - Describes the selection of enhancement modes for decoding barcodes of poor or degraded quality.
      • AdaptiveScanning - Enable or Disable Adaptive scanning.
      • BeamWidth - Controls the beam width of the laser scanner.
      • GS1LimitedSecurityLevel - Security level addition of GS1 DataBar lim decoder.
  4. Enhanced DataCapture feature in the Profile Manager:
    • Added new reader parameters:
      • Aim Timer - Sets the duration (in ms) for timed aim modes.
      • Viewfinder Size - Sets the View Finder window size in camera scanner as a percentage of full width and full height.
      • Viewfinder X Offset - Sets the X axis position of the top left corner of the view finder.
      • Viewfinder Y Offset - Sets the Y axis position of the top left corner of the view finder.
      • Character Set Selection - Allows the user to convert the barcode data if different from default encoding type.
      • Added new values for Aim Type:
      • Timed Hold - Once trigger is pressed, an aiming session is started for a time specified by Aim Timer. When this time expires, a decode session is started and scan beam will be visible. The decode session will remain active until the Beam Timer expires, the trigger is released or a barcode is decoded.
      • Timed Release - Once the trigger is pressed, an aiming session is started and will continue until the trigger is released. If the Aim Timer is expired when the trigger is released, a decode session will be started with scan beam visible for a remaining time equal to Beam Timer or a barcode is decoded.
      • Press And Release - The scan beam starts when the trigger is pressed and released. The decode session will remain active until the Beam Timer expires or a barcode is decoded.
      • Added new values for Character Set Selection:
      • ISO-8859-1 - Allows the user to convert the barcode data using ISO-8859-1 character encoding type.
      • Shift_JIS - Allows the user to convert the barcode data using Shift_JIS character encoding type.
      • UTF-8 - Allows the user to convert the barcode data using UTF-8 character encoding type.
  5. Enhanced the performance of using decodeAudioFeedbackUri in ScannerConfig.ScannerParams in Barcode Manager API.
  6. The ProfileConfig class which can be used to access the profile data has been deprecated. It is recommended to use the name-value pairfunction of Profile Manager feature. The Profile XML can also be directly modified. Refer to the Clock Sample for information on modifying Profile XML data.
  7. Fixed: Toggling Hard trigger and soft trigger sometimes results into cancel read exception.
  8. Fixed: In earlier versions, selecting EMDK APIs as target Compile Sdk Version in the Android Studio project would result in the compilation error. This issue is now fixed.

I am one of those people that doesn't watch much television. Besides live sport events (mainly US football), I find it somewhat a waste of time. I was at a recent party with some friends and they were all talking about the 'hit' show 'The Walking Dead', a show about how humans are surviving a zombie apocalypse. The show is pretty much filled with how many ways to kill zombies and then how to kill humans who piss you off. To me this 'investment' of my time to consume such a show in order to be entertained and then in turn more time socializing about it, doesn't really give me the ROI I am looking for. I mean life is short right? I don't have time for such nonsense, I would much rather write some code or  spend my time reading. Novels are not my thing, so I fill up my reading with lots of small online articles that will ultimately help me in some way. Of course being a developer, I read lots of technical based articles, but the articles that I absolutely can't get enough of, are ones that can be applied across all aspects of my personal and professional life. Come on what's better then a 10 minute read that you can then apply to everything you do. That is the ROI I am looking for.


What does all of this talk about zombies have to do with 'sunk cost fallacy' and how you write code. Well so glad you asked. You may not have heard of the term 'sunk cost fallacy' before, so I strongly urge that you read this fascinating article that is rooted in the topic of decision making. What fascinated me the most was realizing that this concept has controlled major life decisions of mine in a negative way, without even realizing it.  Talk about being a zombie. How could I let this happen.


Take for example one of many 'ah-hah' moments from the article:



Let’s pretend you have three projects going on. You have $1,000 invested in one project, $5,000 invested in another, and $25,000 invested in the third. I tell you that you have to eliminate two of the projects, and only focus on one.


Which do you choose?


Well, if you’re like most people, you’d answer this question without even asking for more information. You don’t even know the expected value (EV) of each project or your level of enjoyment from them. Not only would most people answer the question with no hesitation, pretty much everyone would choose the project they’d invested $25k in, even if the expected value or happiness from the other projects were higher. Sunk cost bias has enormous control over most people’s minds, influencing them to make incredibly flawed decisions.



The definition of a 'sunk cost' is a cost that has already been incurred and cannot be recovered. So, why is this important? So let's say we invested the past 2 months in developing the next killer application, but then we realize that it has been architected completely wrong or that it has severe usability issues. Let's say the 2 months equals around $10,000 in time and money. What would you say the "value" we should put on those costs will be in factoring our decision for moving forward? You would probably say $10,000. Right? Why would it not be? Well the value we should be putting on this 'sunk cost' should really be $0. That's right - zero dollars - as in nothing, zilch, nada, zippo. Stop and read this again until it sinks in.  Our brain is so wired that we believe the time or money we already have invested into something, should be factored into our current decision making. This is flawed logic.


How could this be true? Wouldn't it cost more if I have to throw away all of that precious code I have been working on tirelessly over the past two months and start over? Think of all of the Red Bull I wasted. What about the weekends I spent coding instead of going to a party talking about the last 'Walking Dead' show I never watched. But my deadline is in another 4 weeks, I can't possibly throw it away and start over. Pretty painful to think about isn't it?


Now take a deep breath - clear you mind - go sit on a yoga mat if you have to for 30 minutes. Now let's think about this another way. What will be the cost of your app being released and no one buys it because it is not even usable? Or worse yet, a large company decided to deploy it to 1000's of users and all of them report it has killed their productivity or their inventory database is now corrupt. This in turn causes the company who just bought your app to lose money, which in turn costs you your reputation, future sales, not to mention time spent dealing with an angry executives and fixing the problems that you should have fixed in the first place. Pretty painful to think about isn't it?


So what decision would have been a better way to go. Well you be the judge - do the math. Don't have your emotion be any part of the equation. Your emotions about your 'investment' is the part of your brain that does the decision making process for you without you even knowing about it. Basically turning you into  zombie. If you eliminate this from your equation, you will be able to realize the true costs and more importantly the expected value you will ultimately get from an alternative decision.  Don't let your choices that you have made in the past dictate and be control of the choices you need to make in the present. Whatever you have spent prior to today is gone - it cannot be recovered - it cannot be unearthed from the grave. Don't let your app get sunk by being a zombie coder.

1. Why does Zebra Technologies need to rebrand the Enterprise products acquired from Motorola Solutions?


Motorola Solutions’ Enterprise Business is now a part of Zebra Technologies. As such, Zebra cannot continue to use Enterprise-related material containing the Motorola Solutions brand. This transition will take us many months to fully complete, and the timing will be different by product family. We will continue to ship Motorola-branded products until stock is depleted. For many products, the rebranding process is well underway.


2. What changes are being made to meet the rebranding requirements?


To meet the requirements for rebranding, changes to both Zebra Hardware and Software products will be required. The Hardware changes will include rebadging as the Motorola logos are replaced with Symbol or Zebra logos and the Regulatory filings are transferred over to Symbol or Zebra Technologies. (The use of the Symbol logo is a temporary strategy that allows us to transition away from the Motorola Solutions brand quickly on Enterprise products in development.)  The new Zebra logo will begin appearing on rebranded and new products shortly.


The Software changes vary by product, and can be divided into 2 levels:


Level 1 – Includes splash screens, icons, Copyright notices and references to Motorola Solutions. These changes are cosmetic only and were specifically selected so as not to impact any device or application functionality, or customer operation. The current Zebra portfolio of Windows Mobile, Windows CE, and Android Jelly Bean products fall into this category, and no changes to any application software should be necessary.


Level 2 – Includes all changes from Level 1 plus:

        • Namespace used for APIs/Applications will be changed to Symbol.
        • Manufacturer Name returned to applications will be Zebra Technologies.

These additional changes will ONLY be made on Android Kit Kat products as they may potentially affect the operation of some software.


3. Which products are impacted by the rebranding?


All Enterprise-related products will receive Level 1 rebranding, unless a product has reached the end of its Life Cycle and has been identified for the standard Zebra End-of-Life process. All other products shipping with Android Kit Kat will receive Level 2 rebranding, EXCEPT for the initial release of the TC70 Enterprise device. Refer to Section 2 for clarification on the Level 1 and Level 2 rebranding changes.


4. How will the rebranding changes for Kit Kat impact applications that were written and tested for Jelly Bean devices?


A primary goal of the rebranding effort has been to minimize the impact to our customers and their business operations. Jelly Bean applications running on rebranded Jelly Bean devices should not be impacted, as the changes are mostly cosmetic. For Kit Kat devices it is expected that most applications will have little or no impact due to rebranding. However, each application should be tested for Kit Kat compatibility. The specific procedures that developers and system administrators should follow resulting from the Level 2 rebranding changes are identified in Section 5.


5. What steps do Software Developers and System Admins need to take as a result of the Level 2 rebranding changes?

References to the Manufacturer Name

Applications that query the device Manufacturer will need to check for a return string of “Zebra Technologies”. Rebranded Kit Kat devices will have the following System Property change:


Android.os.Build.MANUFACTURER = Zebra Technologies

Rho Mobile Suite

Formal support for rebranded Kit Kat devices will be available in RMS 5.2. As an application development framework, to meet the security requirements of Kit Kat, and to take advantage of new features, customer applications will need to be recompiled to operate on RMS 5.2.

Deprecation Highlights

As part of the transition from Motorola to Zebra, a number of components were rebranded. While all efforts have been made to limit the impact of the rebranding on existing applications, applications written for Motorola branded devices may require modifications to run on Zebra devices. The following are some of the important points to consider while modifying your applications:


1.     Determining if a device is rebranded – In most cases, it is possible to write a common application to run on both Zebra as well as Motorola branded devices. The following method can be used to determine if a device is rebranded:


Use the “android.os.Build.MANUFACTURER” field for determining if a device is Zebra branded. Rebranded devices are set to “Zebra Technologies” whereas Motorola devices are set to “Motorola Solutions”.

2.     Package names – All packages using the Motorola name (com.motorola..) have been rebranded. Applications performing operations such as launching a package must be modified to use the rebranded (com.symbol..) package name.

3.     API Intents – All intents previously using the com.motorola naming convention have been rebranded to use the com.symbol naming convention. While not documented for new use, the older Motorola named intents (com.motorola…) will still be supported for backward compatibility but they are being deprecated. Zebra will remove support for Motorola intents in the near future. It is strongly recommended that applications are modified to use the Zebra rebranded intents as soon as possible.

4.     EMDK APIs – The EMDK APIs do not require any code changes or recompilation.

5. Legacy configuration mechanisms – A few deployments use Zebra supplied application specific tools and utilities to perform configuration of devices (for example, provisioning APKs). Although these tools and utilities are not being updated to include new features, they have been rebranded and support backwards compatibility. Customers using these utilities should request the updated versions for use on rebranded terminals from the same channel that the original APK was obtained.

6. Enterprise Utilities – The MultiUser Administrator, AppLock Administrator and the Secure Storage Administrator make up the on-device Enterprise Utilities. Version 4.0 and later of these utilities will support both rebranded and non-rebranded devices. Customers using these utilities will need to upgrade to Version 4.0 or later.

Additional specifics are provided below for the rebranded versions of the EMDK, DataWedge, and the EHS APK.

EMDK – Included in newer Device Operating System (OS) Images. The device compatibility process does not change

Package Name

None of the EMDK components require any rebranding. The EMDK Package name remains the same:

Existing Package Name

Rebranded Package Name




There is no rebranding impact on the EMDK APIs. Applications developed using the existing EMDK can be used on Zebra branded as well as legacy Motorola branded devices. There is no need for code modification or recompilation.

DataWedge – Included in Device OS Images

Package Name

The DataWedge package has been rebranded as follows:


Existing Package Name

Rebranded Package Name




The existing DataWedge profiles (stored in the datawedge.db file) are fully compatible with the rebranded DataWedge. There is no need for any modifications.

API Intents

The existing DataWedge API intents are still supported for backward compatibility but they are being deprecated. It is strongly recommended that applications are modified to use the rebranded intents as soon as possible:


Existing Intent Name

Rebranded Intent Name

















EHS Version 2.0 supports rebranded devices

Package Name

The EHS package has been rebranded as listed below:


Existing Package/Main Activity Name

Rebranded Package/Main Activity Name





Configuration File

The existing EHS configuration (stored in the enterprisehomescreen.xml file) is fully compatible with the rebranded EHS. There is no need to make any modifications.

API Intents

The existing EHS API intents are still supported for backward compatibility but they are being deprecated. It is strongly recommended that applications are modified to use the rebranded intents as soon as possible:


Existing Intent Name

Rebranded Intent Name






For Mobile Device Management Solutions (MDMs)


MDM vendors are rebranding their agents to support our rebranded devices. Rebranded Kit Kat OS builds have rebranded MDM Clients already embedded in the OS. Those Clients are compatible with specific Agents that support rebranding.


Please refer to the Launchpad site ( for upgrade guidance that applies to your specific scenarios.


For Additional Questions


It is critical that we continue to serve our customers with the highest quality of service that defines our brand. Should you have questions regarding the rebranding process, please refer to the Launchpad site for guidance.

EMDK Projects in Android Studio

By now you have probably seen Google has released the new IDE for Android development, Android Studio. This new IDE is based on IntelliJ IDEA and thus no longer uses Eclipse. Prior to Android Studio, there were basically two options:

  • ADT Bundle
  • Ecliplse with ADT plugin for Eclipse

The current EMDK For Android supports both of these options (however you can no longer download ADT Bundle) and during the installation of EMDK For Android, one of the first prompts asks you which option you choose. Fear not, although we do not yet officially support Android Studio – you can still use it to build EMDK for Android based applications.

Using the ADT Plugin for Eclipse

During the installation of EMDK for Android, you are asked about your Android development environment:


If you are starting fresh,you would need to install stand alone Eclipse and the Android SDK separately and then provide the paths to each. Head over to the EMDK Setup guide for all of the not-so gory details.


Now you will be all set. Even though you may want to use Android Studio for development, we currently don’t have full integration, so you will need to have this Eclipse setup handy when you want to use Profile Manager features. If you just want to use the Native Barcode Java APIs, then you can practically use Android Studio stand alone.

Importing Existing EMDK Projects

Once you install Android Studio, you will want to import one of our samples to just test things out before you start/continue any full development. It is probably a good idea to just build a basic Android app using the Android Studio project wizards (they have some really cool new templates like Google Maps and Cloud Services).

  1. From Android Studio, select File\Import Project


  2. Then put in the folder where the samples are locations C:\Users\Public\Symbol EMDK for Android\v3.0\Samples\ADT. You should see the list of samples:


  3. Keep the rest of the default settings in the Import Wizard.



  4. It will then crank out a new Android Studio project and give you a nice report saying what it did. Pay attention to the new project structure (which is quite different then previous Android projects)



  5. Now wait a few minutes for the Gradle scripts to finish executing.

If there were no errors, then you should be able to just launch the application without any issues.

Fixing the SDK Linkage

After the Gradle script completed, you may notice an error in your project.If you open the file, you will see that it does not recognize the EMDK libraries.


Have no fear, this can easily be fixed. Right click on the project and select Open Module Settings.


In the Compile Sdk Version, you will notice that the EMDK version is not listed.


All you need to do is manually type it in. Either enter Symbol Technologies, Inc.:EMDK 3.0 (API 19):19 or Symbol Technologies, Inc.:EMDK 3.0 (API 16):16


After the Gradle scripts finish executing, there should no longer be any errors and you can then run the project.


If your project uses the Profile Manager features, you know there is a EMDKConfig.xml file that resided in the Assets folder. Under the new Android Studio project, you will also see it under the assets folder under the app folder:


Since we do not yet have the Profile Manager wizard integrated, you will not be able to generate this XML file directly from inside of Android Studio. This is where the previous Eclipse installation comes in handy. Simply generate the XML file within Eclipse and then copy it to your Android Studio project.


Creating New Projects

You can use the Android New Project wizard to start new development, however after creating the project you still need to follow the Fixing the SDK Linkage section above to properly enable the EMDK For Android. As of now the EMDK option does not come up in the list, you have to manually enter it (as mentioned above). You can then follow any of the previous tutorials we have – of course ignoring anything that mentioned ADT Bundle or shows the old project wizards.


Let me know what you think about Android Studio – would love to hear any feedback on how we can make your EMDK For Android developer experience a better one. Stay tuned for further developments on Android Studio.

Scan barcodes using DataWedge Intents in Xamarin Android


This guide will walk you through creating a Xamarin Android Application that will scan barcodes on a Symbol Android device using DataWedge Intents. Basically, the tutorial will use a DataWedge profile that we need to create, through which it will send the scanned barcode data to our Xamarin Android application using Intents. The user can scan barcodes using a hard scan trigger on the device, where the app would receive barcode data through DataWedge. The tutorial also allows you to scan barcodes by toggling from hard to soft scan by pressing a button specified in the app itself. Since Xamarin uses C#, we will code using C# in our Xamarin Android application.

Note: You can go through this quick start to get familiar with Xamarin Android.


  • Java Development Kit (JDK)
  • Android SDK
  • Install Xamarin Android on your Mac/Windows machine using guidelines mentioned here
  • Symbol Android Device (MC40, TC70, TC55)

Note: This tutorial uses Xamarin studio for app development. You can use either Visual Studio or Xamarin Studio.

Creating The Project

  1. Launch the Xamarin Studio


  2. Create a new Solution



  3. Select “Android” section under “C#” on the left hand side and you will see different options of creating Android Project.


  4. Select “Android Application” and provide application name in the “Name” field (Ex. barcodescanner).


    Note: You can set different location for the project based on your workspace.

  5. Click “OK” and the project will be created.


Updating Manifest

  1. Modify the Application’s AndroidManifest.xml to receive Intents from a Profile of DataWedge application that we will be creating later.

    Initially the AndroidManifest.xml file looks like:


    Remove all the existing code and add following code:

     <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="" android:versionCode="1" android:versionName="1.0" package="barcodescanner.barcodescanner">    <uses-sdk android:targetSdkVersion="19" android:minSdkVersion="16" />    <application android:icon="@drawable/icon" android:label="barcodescanner">     <activity android:name=".MainActivity" android:label="barcodescanner" android:launchMode="singleTask">      <intent-filter>        <action android:name="barcodescanner.RECVR" />        <category android:name="android.intent.category.DEFAULT" />      </intent-filter>     </activity>    </application> </manifest> 

    we have added the MainActivity in application tag. This MainActivity has has the Intent Filters that specifies a Receiver through which the app would receive Intent from DataWedge application for its MainActivity.

    You can also see that activity tag has an attribute android:launchMode="singleTask" that provides only one instance of the Activity, which handles all new incoming Intents.

    When done, your manifest.xml should look like:


Adding Some Code

  1. Now we will start to add some code.

    First, Lets add a simple User Interface that contains a Text View as a label and  an Edit Text that will display Barcode data to the user.

    So go to Resources -> layout -> Main.axml and remove all the existing code. Add the following code to Main.axml:

     <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=""    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:minWidth="25px"    android:minHeight="25px">      <TextView        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_margin="10dip"        android:text="Barcode Data:"        android:textSize="18sp"        android:textStyle="bold" />      <EditText        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:inputType="textMultiLine"        android:id="@+id/editbox" />      <Button        android:id="@+id/btn_scan"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center_horizontal"        android:layout_margin="20dip"        android:gravity="center"        android:text="Scan" /> </LinearLayout> 

    Now, your Main.axml file should look like:


  2. Once done with User Interface, we will now add some C# code in MainActivity.cs to get the scanned barcode data through DataWedge application profile using Intent and display it in the User Interface.

    So open the MainActivity.cs file that looks like:


    Remove the existing code from OnCreate method including variables and Activity information just above MainActivity class. The MainActivity.cs should now look like:


  3. Remove all the existing using imports in MainActivity.cs add add the following imports that let you use required components in the application.

     using System;
     using Android.App;
     using Android.Content;
     using Android.Runtime;
     using Android.Views;
     using Android.Widget;
     using Android.OS;
     using Android.Text;
     using Android.Text.Style;
     using Android.Graphics;

    We need to add manifest attributes such as Activities and Intent Filters to our MainActivity.cs in order to make our code work. So add the following code just above MainActivity class in MainActivity.cs.

    Note: For more Information please go through Working with AndroidManifest.xml

     [Activity (Name="barcodescanner.barcodescanner.MainActivity", Label = "barcodescanner", 
     LaunchMode = Android.Content.PM.LaunchMode.SingleTask , MainLauncher = true, Icon = "@drawable/icon")]
     [IntentFilter(new string[] { "barcodescanner.RECVR" }, Categories = new[] { Intent.CategoryDefault })]

    Your code with the imports and manifest attributes should look like:


  4. Lets declare some global variables in MainActivity class that we would be using in our application. Some of these variables hold the Intent information such as source-tag, label-type and data-string of the scanned barcode data coming through DataWedge application. The variable ourIntentAction holds the Intent Action for our operation and editText holds the UI information, which in this tutorial is barcode data. ACTION_SOFTSCANTRIGGER is the Intent Action that is sent to DataWedge application whenever the user presses scan button in application. This action is supported with extra data (DWAPI_TOGGLE_SCANNING) that lets data wedge application Toggle from hard to soft scan whenever the scan button in the app is pressed.

     // This intent string contains the source of the data as a string  
     private static string SOURCE_TAG = "com.motorolasolutions.emdk.datawedge.source";
     // This intent string contains the barcode symbology as a string  
     private static string LABEL_TYPE_TAG = "com.motorolasolutions.emdk.datawedge.label_type";
     // This intent string contains the captured data as a string  
     // (in the case of MSR this data string contains a concatenation of the track data)  
     private static string DATA_STRING_TAG = "com.motorolasolutions.emdk.datawedge.data_string";
     // Intent Action for our operation
     private static string ourIntentAction = "barcodescanner.RECVR";
     // Let's define the API intent strings for the soft scan trigger
     private static String ACTION_SOFTSCANTRIGGER = "com.motorolasolutions.emdk.datawedge.api.ACTION_SOFTSCANTRIGGER";
     private static String EXTRA_PARAM = "com.motorolasolutions.emdk.datawedge.api.EXTRA_PARAMETER";
     private static String DWAPI_TOGGLE_SCANNING = "TOGGLE_SCANNING";
     // EditText to hold Barcode data
     private EditText editText;
  5. We will now configure OnCreate method by adding following code below the base.OnCreate (bundle);:

     // Set our view from the "main" layout resource
     // Get our button from the layout resource,
     // and attach an event to it
     editText = FindViewById<EditText>(Resource.Id.editbox);
     // Get our button from the layout resource,
     // and attach an event to toggle scanning option
     Button scanButton = FindViewById<Button> (Resource.Id.btn_scan);
     scanButton.Click += delegate {
         var intent = new Intent();    
     } ;

    This code block refers to Main.axml to get the User Interface for Main Activity. It refers to the UI elements declared in the Main.axml layout. After that it has an on click listener for “Scan” button that broadcasts the Intent to DataWedge application with specified Intent Action and Extra Data in order to change modes from hard to soft scan once the “Scan” button is pressed.

    So the code with global variables and OnCreate method should look like:


  6. In this step, we would specify handleDecodeData method that accepts Intent with scanned barcode information. We will extract this barcode information and display to the user in this method.

     // Receives the Intent that has barcode info and displays to the user
     private void handleDecodeData(Android.Content.Intent i)
           // check the intent action is for us  
           if (i.Action.Equals(ourIntentAction))
               // define a string that will hold our output  
               String Out = "";
               // get the source of the data  
               String source = i.GetStringExtra(SOURCE_TAG);
               // save it to use later  
               if (source == null) source = "scanner";
               // get the data from the intent  
               String data = i.GetStringExtra(DATA_STRING_TAG);
               // let's define a variable for the data length  
               int data_len = 0;
               // and set it to the length of the data  
               if (data != null) data_len = data.Length;
               // check if the data has come from the barcode scanner  
               if (source.Equals("scanner"))
                   // check if there is anything in the data  
                   if (data != null && data.Length > 0)
                       // we have some data, so let's get it's symbology  
                       String sLabelType = i.GetStringExtra(LABEL_TYPE_TAG);
                       // check if the string is empty  
                       if (sLabelType != null && sLabelType.Length > 0)
                           // format of the label type string is LABEL-TYPE-SYMBOLOGY  
                           // so let's skip the LABEL-TYPE- portion to get just the symbology  
                           sLabelType = sLabelType.Substring(11);
                           // the string was empty so let's set it to "Unknown"  
                           sLabelType = "Unknown";
                       // let's construct the beginning of our output string  
                       Out = "Source: Scanner, " + "Symbology: " + sLabelType + ", Length: " + data_len.ToString() + ", Data: ...\r\n";
               // check if the data has come from the MSR  
               if (source.Equals("msr"))
                   // construct the beginning of our output string  
                   Out = "Source: MSR, Length: " + data_len.ToString() + ", Data: ...\r\n";
               // we need to put the edit box text into a spannable string builder  
               SpannableStringBuilder stringbuilder = new SpannableStringBuilder(editText.Text);
               // add the output string we constructed earlier  
               // now let's highlight our output string in bold type  
               //stringbuilder.SetSpan(new StyleSpan(Typeface.DefaultBold), et.Text.Length, stringbuilder.Length, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);  
               // then add the barcode or msr data, plus a new line, and add it to the string builder  
               stringbuilder.Append(data + "\r\n");
               // now let's update the text in the edit box  
               editText.SetText(stringbuilder.ToString(), null);
               // we want the text cursor to be at the end of the edit box  
               // so let's get the edit box text again  
               // and set the cursor position at the end of the text  
               // and we are done!  

    As you can see the method receives an Intent object. It then fetches source data of the Intent along with data string that are passed from DataWedge as EXTRA strings in the Intent. The method then checks for scanner device types such as Scanner and MSR, which is going to be Scanner in this tutorial. Based on the scanner device (Scanner), the method would form the output data string that contains barcode data and display it in the Edit Text that we specified in layout.

    So the handleDecodeData method should look like:

    Note: Since the handleDecodeData method is too long, it’s been divided into multiple screen captures.




  7. Finally, we would override OnNewIntent method that primarily receives the Intent sent by our DataWedge profile whenever a barcode is scanned. This method would in turn call handleDecodeData method to get the barcode data, format it and display it to the user.

    Add following code for OnNewIntent method:

     // Receives Intent from DataWedge application that has barcode data 
     protected override void OnNewIntent(Intent i)

    The method OnNewIntent looks like:


That’s it!!! We are done with all the coding part that will let us capture the Intent sent by DataWedge Profile whenever a barcode is scanned. This Intent has the barcode data that would be extracted and displayed in our Xamarin Android application.

Note: We have not yet created the DataWedge Profile for our Xamarin Android application. We will create it after we run the application so that the profile can see our “barcodescanner” application in the list of available applications.

Running the Application

  1. Connect the device to USB port.

    Make sure the device is in USB debug.

    In order to run the application on device, select your connected Symbol device under “Physical Devices” in the drop-down.



  2. Run the application by pressing img  button on the top left corner of Xamarin Studio.


    As we have not created the “DataWedge Profile” yet, we will not get the formatted barcode data in the EditText after scanning barcodes. So lets create one.

  3. Creating a DataWedge Profile:














    • Open DataWedge application.
    • You can see different DataWedge Profiles associated with their different respective applications. Now we need to create a DataWedge Profile specific to our Android application that we have created and installed on Symbol device. So click the Menu button and select “New Profile” option.
    • Enter some Profile Name (Ex. Xamarin-Profile) and press “OK”.
    • The profile is now created. We need to configure the profile to output a barcode Intent to our Xamarin Android application when a barcode is scanned. So tap on the profile we created.
    • Now associate our application to this profile by clicking “Associated apps” option. This will let the profile know to pass Intent having barcode data to our application every time a barcode is scanned.
    • Press menu and select “New app/activity” option.
    • Select our Xamarin Android application from the list (barcodescanner.barcodescanner).
    • Select the Activity where you want your app to receive Intent. In our case, it would be barcodescanner.barcodescanner.MainActivity. So select that option and you should see following.
    • Hit the Back button and scroll down a bit and disable the “Keystroke Output” option.
    • Scroll down and Enable the “Intent Output” option, which allows your application to receive information via Intents.
    • Just below that, click the “Intent Action” option and specify the Intent action name that we mentioned in our Xamarin  AndroidManifest.xml file (barcodescanner.RECVR) and press “OK”

      Note: The Intent Action Name in the Xamarin manifest and DataWedge Profile should be identical.

    • Just below that, click the “Intent Category” option and specify the Intent category name that we mentioned in our apps manifest file (android.intent.category.DEFAULT) and Press “OK”
    • So now we have successfully created a DataWedge Profile (Xamarin-Profile) that transfers the Intents having barcode data to our Xamarin Android application (barcodescanner).
  4. So open the Xamarin Android application named “barcodescanner” that we created.


  5. Now scan barcodes using hard scan trigger as well as the soft scan key in the application and you should see the formatted barcode data successfully received through our DataWedge Profile and displayed on the Edit Text of our Xamarin Android application.


Important Programming Tips

  1. It is required to add the manifest configurations in MainActivity.cs file to make them work properly.


     [Activity (Name="barcodescanner.barcodescanner.MainActivity", Label = "barcodescanner", 
     LaunchMode = Android.Content.PM.LaunchMode.SingleTask , MainLauncher = true, Icon = "@drawable/icon")]
     [IntentFilter(new string[] { "barcodescanner.RECVR" }, Categories = new[] { Intent.CategoryDefault })]
  2. Make sure you check the compatibility of the Xamarin and Xa

Filter Blog

By date:
By tag: