Android Print intent

2020-02-12 04:57发布

问题:

I noticed handful of printer applications in Android Market (HP, Epson, Canon, Kodak, Brother, Samsung, Lexmark etc) allows user to make LAN printing. But i could not find any generic intent to invoke them.

Intent.ACTION_VIEW is opening up all applications which can view the photo/doc including many productivity apps.

Looks like HP iPrint app has some unique intent string, but its not working for any other print app.

Intent printIntent = new Intent("org.androidprinting.intent.action.SEND");

Any clue or workaround to invoke only print related applications when creating an intent ?

回答1:

There's no built-in way to find an application that responds to "print". Even if you know the application can print to a printer, you have no guarantee that the application will accept incoming intents. If it does accept incoming intents, you have to hope that it can accept an intent to print, and then hope that the developer documented how to use the intent.

The best way to find the application you want is to Google for it.



回答2:

Not sure if you're still looking for a solution, but Google's Cloud Print service is supposed to address the issue.

Haven't tried integrating the code yet, but it's set up as an all-API-compatible Java source file and corresponding XML layout to create a 'PrintDialog' that you can shoot an intent to within your code. Right now they're saying it works better with PDF-formatted documents, and can maybe handle web-friendly image files, so you may need to incorporate some 3rd-party/open-source PDF-generation depending on what you're printing.

Might check out Google's FAQ as well, since it discusses security concerns and what it takes to make non-cloud-aware printers work with the service. (Looks like there's a software dongle that users would have to install themselves.)

Hope that helps.



回答3:

Samsung Mobile Print supports intents. You can print, scan or send fax from your application using intents.

For web printing sample see here