0

I am trying to implement a PrintService. I am using Network Service Discovery (NSD) to find the printers (c.f. https://developer.android.com/training/connect-devices-wirelessly/nsd.html, etc) Both the NsdManager.DiscoveryListener and the NsdManager.ResolveListener make asynchronous calls. However, the system calls my onStartPrinterDiscovery() before the NSD functions are called. I don't see any other opportunity to call addPrinters().

How can this work?

Baris Demiray
  • 1,539
  • 24
  • 35
Robert R Evans
  • 177
  • 1
  • 11
  • I think the answer may be to have the DiscoveryListener send a Message to my PrintService. When I get this tested, I'll post it as the answer – Robert R Evans Nov 23 '16 at 18:11

1 Answers1

1

onStartPrinterDiscovery() only tells you to start discovery, you need to call addPrinters() every time you discover a new printer (or an existing one has been removed) so you can do that in your listener.

Nonos
  • 2,450
  • 2
  • 23
  • 34
  • I suspect that this, with my comment above, is the solution. I'll try it out next week and accept it as appropriate. Thanks for your help – Robert R Evans Jan 25 '17 at 18:41