Share via


PrinterDiscoverySession Class

Definition

This class encapsulates the interaction between a print service and the system during printer discovery.

[Android.Runtime.Register("android/printservice/PrinterDiscoverySession", DoNotGenerateAcw=true)]
public abstract class PrinterDiscoverySession : Java.Lang.Object
[<Android.Runtime.Register("android/printservice/PrinterDiscoverySession", DoNotGenerateAcw=true)>]
type PrinterDiscoverySession = class
    inherit Object
Inheritance
PrinterDiscoverySession
Attributes

Remarks

This class encapsulates the interaction between a print service and the system during printer discovery. During printer discovery you are responsible for adding discovered printers, removing previously added printers that disappeared, and updating already added printers.

During the lifetime of this session you may be asked to start and stop performing printer discovery multiple times. You will receive a call to PrinterDiscoverySession#onStartPrinterDiscovery(List) to start printer discovery and a call to PrinterDiscoverySession#onStopPrinterDiscovery() to stop printer discovery. When the system is no longer interested in printers discovered by this session you will receive a call to #onDestroy() at which point the system will no longer call into the session and all the session methods will do nothing.

Discovered printers are added by invoking PrinterDiscoverySession#addPrinters(List). Added printers that disappeared are removed by invoking PrinterDiscoverySession#removePrinters(List). Added printers whose properties or capabilities changed are updated through a call to PrinterDiscoverySession#addPrinters(List). The printers added in this session can be acquired via #getPrinters() where the returned printers will be an up-to-date snapshot of the printers that you reported during the session. Printers are <strong>not</strong> persisted across sessions.

The system will make a call to #onValidatePrinters(List) if you need to update some printers. It is possible that you add a printer without specifying its capabilities. This enables you to avoid querying all discovered printers for their capabilities, rather querying the capabilities of a printer only if necessary. For example, the system will request that you update a printer if it gets selected by the user. When validating printers you do not need to provide the printers' capabilities but may do so.

If the system is interested in being constantly updated for the state of a printer you will receive a call to #onStartPrinterStateTracking(PrinterId) after which you will have to do a best effort to keep the system updated for changes in the printer state and capabilities. You also <strong>must</strong> update the printer capabilities if you did not provide them when adding it, or the printer will be ignored. When the system is no longer interested in getting updates for a printer you will receive a call to #onStopPrinterStateTracking( PrinterId).

<strong>Note: </strong> All callbacks in this class are executed on the main application thread. You also have to invoke any method of this class on the main application thread.

Java documentation for android.printservice.PrinterDiscoverySession.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

PrinterDiscoverySession()

Constructor.

PrinterDiscoverySession(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsDestroyed

Gets whether the session is destroyed.

IsPrinterDiscoveryStarted

Gets whether printer discovery is started.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
Printers

Gets the printers reported in this session.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

TrackedPrinters

Gets the printers that should be tracked.

Methods

AddPrinters(IList<PrinterInfo>)

Adds discovered printers.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
OnDestroy()

Notifies you that the session is destroyed.

OnRequestCustomPrinterIcon(PrinterId, CancellationSignal, CustomPrinterIconCallback)

Called by the system to request the custom icon for a printer.

OnStartPrinterDiscovery(IList<PrinterId>)

Callback asking you to start printer discovery.

OnStartPrinterStateTracking(PrinterId)

Callback asking you to start tracking the state of a printer.

OnStopPrinterDiscovery()

Callback notifying you that you should stop printer discovery.

OnStopPrinterStateTracking(PrinterId)

Callback asking you to stop tracking the state of a printer.

OnValidatePrinters(IList<PrinterId>)

Callback asking you to validate that the given printers are valid, that is they exist.

RemovePrinters(IList<PrinterId>)

Removes added printers.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to