Android Question check if something is printed

zmrcic

Member
Licensed User
Longtime User
Hi...
I have Android device with an integrated printer. Make and model are irrelevant. My app must collect printed data, so the manufacturer created a small API for that. I'm accessing that API on timer, but if I can somehow see that something is being printed I can only then access API functions. it's like monitoring a printer queue in Windows, and if something is printed go to collect data.
 

drgottjr

Expert
Licensed User
Longtime User
there are 2 ways to determine if a print job has finished (one is by polling, the other is a callback). but you need to know how the os actually achieves printing. a device with an integrated printer is going involve custom hardware and software (although, somewhere along the line, one would suppose that android's standard printer classes come into play).
you need to access either the printjob or the printdocumentadapter. they hold the key to knowing when the job has finished. perhaps the manufacturer who provided the api can help. the printdocumentadapter provides a callback. the printjob would let you do a polling loop (obviously not the best solution, but you could make its timing minimally invasive). a tiny getter (which you would call at the start of printing) would provide the necessary object. if they made the printjob or the printdocumentadapter public and assigned it at that point, you could "get" it. you might also be able to get it via reflection, but you need access to whatever software is driving the printer.
 
Upvote 0

emexes

Expert
Licensed User
Longtime User
there are 2 ways to determine if a print job has finished

A third way, if you want confirmation that the printout has made it out of the print buffer and is actually on paper without having run out of ink or ribbon, would be to print a short (say four digit) number at the bottom of the printout, and not give up printing until the user types in that number to verify the printout is in their hand. That handily solves the issue of when the user needs to reprint the document because the first try paper jammed or whatever.

Or instead of a number, you could have a set of 23 words and randomly print 3 of them.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…