9

I'm developing a print service on android. The list of available printers changes quite often. However, I have not been able to find a way of removing the non-existing printers (i.e. printers that were available at some point). These printers appear grayed-out on my test devices.

I can see 'zombie' printers in PrinterDiscoverySession's onStartPrinterDiscovery() and onValidatePrinters() methods but do not know how to get rid of them. Calling session's addPrinters() with existing printers or removePrinters() with non-existing ones does not help.

I'd appreciate any suggestions. Thanks.

bdristan
  • 1,048
  • 1
  • 12
  • 36

2 Answers2

1

From the android default print service print menu:

  1. Select the down arrow in the available printer list.
  2. Select "All Printers".
  3. Select "Add Printer".
  4. Select "Default Print Service".
  5. You will see "Saved Printers"
  6. Select the printer that you would like to remove from the list.
  7. Select "Forget"
  8. Back space out to the available printers list.
  • For network printers: If the printer is no longer on the network, the service cannot "see" it. It has to be on the network for the service to first recognize it and then it can be selected and a tap of "Forget" will git rid of it after it is again removed from the network. – AdvApp Jan 31 '23 at 02:06
0

PrinterDiscoverySession.GetPrinters() this will give you a list List<PrinterInfo> with PrinterInfo. You can search the list of Printers for where STATUS_UNAVAILABLE is not 0

Check out these for probably a clearer answer:

PrinterDiscoverySession()

GetPrinters()

PrinterInfo

STATUS_UNAVAILABLE ("Returns int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR")

Another option may be

Another way is to use PrinterInfo.GetStatus()

m4n0
  • 29,823
  • 27
  • 76
  • 89
Scott Uphus
  • 86
  • 3
  • 14