Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8833521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:47:57+00:00 2026-06-14T08:47:57+00:00

I have created a Mono for Android application which uses the Zebra printing API.

  • 0

I have created a Mono for Android application which uses the Zebra printing API. I have managed to get the ZSDK_API.jar file referenced in both a Java Bindings Library and a Standard Mono for Android application as defined HERE

  • I have added the .jar file to the JBL project (Jars folder) and set it’s build action to InputJar
  • I also added the jar to the Mono for Android application with the build action set to AndroidJavaLibrary.

DiscoveryHandler

public class DiscoveryHandler : IDiscoveryHandler
{
    private Discovery _reference;

    public DiscoveryHandler(Discovery reference)
    {
        _reference = reference;
    }

    public void DiscoveryError(string message)
    {
        new UIHelper(_reference).showErrorDialogOnGuiThread(message);
    }

    public void DiscoveryFinished()
    {
        _reference.RunOnUiThread(() =>
        {
            Toast.MakeText(_reference, " Discovered " + _reference.discoveredPrinters.Count + " devices", ToastLength.Short).Show();
            _reference.SetProgressBarIndeterminateVisibility(false);
        });
    }

    public void FoundPrinter(DiscoveredPrinter printer)
    {
        _reference.RunOnUiThread(() => 
        {
            DiscoveredPrinterBluetooth p = (DiscoveredPrinterBluetooth)printer;
            _reference.discoveredPrinters.Add(p.Address + " (" + p.FriendlyName + ")");
            _reference.mArrayAdapter.NotifyDataSetChanged();
        }); 
    }

    public void Dispose()
    {

    }

    public IntPtr Handle
    {
        get { return _reference.Handle; }
    }
}

Discovery.cs

public class Discovery : ListActivity
{
    public List<string> discoveredPrinters = null;
    public ArrayAdapter<string> mArrayAdapter;
    private static IDiscoveryHandler btDiscoveryHandler = null;


    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        RequestWindowFeature(WindowFeatures.IndeterminateProgress);
        SetContentView(Resource.Layout.discovery_results);

        SetProgressBarIndeterminateVisibility(true);
        discoveredPrinters = new List<string>();
        SetupListAdapter();
        btDiscoveryHandler = new DiscoveryHandler(this);

        try
        {
            new Thread(new ThreadStart(() =>
                {
                    Looper.Prepare();

                    try
                    {
                        RunOnUiThread(() => Toast.MakeText(this, "Trying", ToastLength.Short).Show());
                        BluetoothDiscoverer.FindPrinters(this, btDiscoveryHandler);
                        RunOnUiThread(() => Toast.MakeText(this, "And...", ToastLength.Short).Show());
                    }
                    catch (ZebraPrinterConnectionException zex)
                    {
                        new UIHelper(this).showErrorDialogOnGuiThread(zex.Message);
                    }
                    catch (ThreadInterruptedException iex)
                    {
                        new UIHelper(this).showErrorDialogOnGuiThread(iex.Message);
                    }
                    catch (Exception ex)
                    {
                        new UIHelper(this).showErrorDialogOnGuiThread(ex.Message);
                    }
                    finally
                    {
                        RunOnUiThread(() => Toast.MakeText(this, "Quitting looper", ToastLength.Short).Show());
                        Looper.MyLooper().Quit();
                        RunOnUiThread(() => Toast.MakeText(this, "Finished", ToastLength.Short).Show());
                    }
                })).Start();
        }
        catch (Exception ex)
        {
            new UIHelper(this).showErrorDialogOnGuiThread(ex.Message);
        }            
    }

    private void SetupListAdapter()
    {
        mArrayAdapter = new ArrayAdapter<string>(this, global::Android.Resource.Layout.SimpleListItem1, discoveredPrinters);
        ListAdapter = mArrayAdapter;
    }
}

I have made sure the manifest is requesting Bluetooth and Bluetooth_Admin as well as internet.

The application builds, but when run simply crashes, no exception and just says “The Application Has Stopped Unexpectedly”

All the classes are being detected and compiled, but I have no idea why it is bombing like this. Has anyone succeeded with a Mono for Android – Zebra integration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:47:59+00:00Added an answer on June 14, 2026 at 8:47 am

    Dammit – I am a chop! Just as I posted it I got to thinking – it probably has something to do with the fact that I was implementing IntPtr Handle as the parent’s handle – I was right. Here is the first step of working code (FIRST STEP – if I have to answer my own questions!):

    public class Discovery : ListActivity, IDiscoveryHandler
    {
        public List<string> discoveredPrinters = null;
        public ArrayAdapter<string> mArrayAdapter;        
    
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.IndeterminateProgress);
            SetContentView(Resource.Layout.discovery_results);
    
            SetProgressBarIndeterminateVisibility(true);
            discoveredPrinters = new List<string>();
            SetupListAdapter();            
    
            try
            {
                new Thread(new ThreadStart(() =>
                    {
                        Looper.Prepare();
    
                        try
                        {                            
                            BluetoothDiscoverer.FindPrinters(this, this);                         
                        }
                        catch (ZebraPrinterConnectionException zex)
                        {
                            new UIHelper(this).showErrorDialogOnGuiThread(zex.Message);
                        }
                        catch (ThreadInterruptedException iex)
                        {
                            new UIHelper(this).showErrorDialogOnGuiThread(iex.Message);
                        }
                        catch (Exception ex)
                        {
                            new UIHelper(this).showErrorDialogOnGuiThread(ex.Message);
                        }
                        finally
                        {
                            RunOnUiThread(() => Toast.MakeText(this, "Quitting looper", ToastLength.Short).Show());
                            Looper.MyLooper().Quit();
                            RunOnUiThread(() => Toast.MakeText(this, "Finished", ToastLength.Short).Show());
                        }
                    })).Start();
            }
            catch (Exception ex)
            {
                new UIHelper(this).showErrorDialogOnGuiThread(ex.Message);
            }            
        }
    
        private void SetupListAdapter()
        {
            mArrayAdapter = new ArrayAdapter<string>(this, global::Android.Resource.Layout.SimpleListItem1, discoveredPrinters);
            ListAdapter = mArrayAdapter;
        }
    
        public void DiscoveryError(string message)
        {
            new UIHelper(this).showErrorDialogOnGuiThread(message);
        }
    
        public void DiscoveryFinished()
        {
            RunOnUiThread(() =>
            {
                Toast.MakeText(this, " Discovered " + discoveredPrinters.Count + " devices", ToastLength.Short).Show();
                SetProgressBarIndeterminateVisibility(false);
            });
        }
    
        public void FoundPrinter(DiscoveredPrinter printer)
        {
            RunOnUiThread(() =>
            {
    
                DiscoveredPrinterBluetooth p = printer.JavaCast<DiscoveredPrinterBluetooth>();
                discoveredPrinters.Add(p.Address + " (" + p.FriendlyName + ")");
                mArrayAdapter.NotifyDataSetChanged();
            }); 
        }
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an android application that calls (using kSOAP library) a SOAP based
I have created an small application, in which I'm using Fluent Nhibernate. Application run
I have created a fairly simple Activity in Mono for Android project: [Activity(Label =
Somehow I managed to get MAC pc OS 10.5.3. I have installed mono, monodevelop
I have created a FileDialog activity in Mono for Android. However, it seems to
I have created a JSP / servlets application running in Tomcat 7. It runs
I have found that my Mono for Android app crashes on each start after
I've installed JDK, Android SDK and Mono Android for Visual Studio 2010, I've created
I have discovered a few issues with ListViews in Mono for Android that may
Pretty new to Mono for Android (C#), and I'm seeming to have trouble during

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.