在没有系统对话框的情况下从android打印

编程入门 行业动态 更新时间:2024-10-28 14:29:42
本文介绍了在没有系统对话框的情况下从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打印

本文发布于:2023-11-05 08:58:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560413.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   情况下   系统   android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!