Print from android without system dialog

2020-07-10 11:04发布

问题:

i would like to print an image from my android application (printer: canon selphy cp910, with wifi direct). I tried the Google API with the android.support.v4.print.PrintHelper class. It work but i have no way to bypass the system dialog. I would like the the application do not interact with the system UI.

user just print the button and start printing on the default connect printer.

Is that possible ?

thank

回答1:

Short answer is unfortunately: no. The only way to use the Android provided print framework is to send the appropriate intent and the system's print spooler app will show the print preview and list of printers to choose from so you can't change that to make it print to the default printer. Also, the android framework does not directly discover or communicate to printers, instead it uses print services in the background to connect to the printer. "A print service must request the android.permission.BIND_PRINT_SERVICE permission to ensure that only the system can bind to it" so you cannot bind to a print service (assuming one is already installed on the device) to perform printing. So it looks like your only option if you don't want a UI to show is to implement connection and printing yourself. Also, how do you know there is a default printer or that it's currently available?