Zebra LinkOS Multiplatform SDK for Xamarin  1.1
Link-OS Portable Class Library Plugin for Xamarin
LinkOS.Plugin.Abstractions.IBluetoothDiscoverer Interface Reference

A class that discovers Bluetooth® devices. More...

Inheritance diagram for LinkOS.Plugin.Abstractions.IBluetoothDiscoverer:
LinkOS.Plugin.BluetoothDiscovererImplementation

Public Member Functions

void FindPrinters (object androidContext, IDiscoveryHandler handler)
 Find Bluetooth® devices that are discoverable. Note: This method will return all devices found, not just Zebra printers Note: This method should not be called from the application main thread. More...
 

Detailed Description

A class that discovers Bluetooth® devices.

Note:Below are 3 methods for doing discovery. They are platform specific. Do not attempt to implement all 3 methods.
Note: There are no cancel discovery methods. Be carefull when using these to properly dispose of discoverer objects if navigating prior to finishing discovery.

using LinkOS.Plugin;
private void StartBluetoothDiscovery()
{
IDiscoveryEventHandler handler = DiscoveryHandlerFactory.Current.GetInstance();
handler.OnDiscoveryError += DiscoveryHandler_OnDiscoveryError;
handler.OnDiscoveryFinished += DiscoveryHandler_OnDiscoveryFinished;
handler.OnFoundPrinter += DiscoveryHandler_OnFoundPrinter;
//For Android
BluetoothDiscoverer.Current.FindPrinters(MainActivity.Context, handler);
//For iOS
BluetoothDiscoverer.Current.FindPrinters(null, handler);
//For Forms apps: implement the previous two methods in OS code projects (PrinterDiscoveryImplementation.cs)
DependencyService.Get<IPrinterDiscovery>().FindBluetoothPrinters(handler);
}
private void OnFoundPrinter(IDiscoveryHandler handler, IDiscoveredPrinter discoveredPrinter)
{
Device.BeginInvokeOnMainThread(() => {
printerList.Add(discoveredPrinter);
});
}
private void OnDiscoveryError(IDiscoveryHandler handler, string message)
{
System.Diagnostics.Debug.WriteLine("Discovery Error: " + message);
}
private void OnDiscoveryFinished(IDiscoveryHandler handler, string message)
{
System.Diagnostics.Debug.WriteLine("Discovery Compete");
}

Member Function Documentation

void LinkOS.Plugin.Abstractions.IBluetoothDiscoverer.FindPrinters ( object  androidContext,
IDiscoveryHandler  handler 
)

Find Bluetooth® devices that are discoverable. Note: This method will return all devices found, not just Zebra printers Note: This method should not be called from the application main thread.

Parameters
androidContextAndroid™ application context. Pass null if iOS implementation.
handlera DiscoveryHandler instance that is used to handle discovery events (e.g. found a printer, errors, discovery finished).

Implemented in LinkOS.Plugin.BluetoothDiscovererImplementation.


The documentation for this interface was generated from the following file: