在没有系统对话框的情况下从android打印 [英] Print from android without system dialog

查看:159
本文介绍了在没有系统对话框的情况下从android打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的android应用程序中打印图像(打印机:canon selphy cp910,使用wifi direct).我使用android.support.v4.print.PrintHelper类尝试了Google API.它可以工作,但是我无法绕过系统对话框. 我希望该应用程序不与系统UI交互.

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.

有可能吗?

谢谢

推荐答案

不幸的是,简短的回答是:否.使用Android提供的打印框架的唯一方法是发送适当的意图,并且系统的打印后台处理程序应用程序将显示打印预览和要选择的打印机列表,因此您无法更改该设置即可将其打印到默认打印机.另外,Android框架不会直接发现打印机或与打印机通信,而是使用打印服务在后台连接到打印机. 打印服务必须请求android.permission.BIND_PRINT_SERVICE权限,以确保只有系统可以绑定到它",因此您不能绑定到打印服务(假设设备上已经安装了一个)来执行打印.因此,如果您不希望显示的UI是实现连接并自己打印,则这似乎是您唯一的选择. 另外,您如何知道默认打印机或当前可用的打印机?

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?

这篇关于在没有系统对话框的情况下从android打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆