打印文件
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 用户经常只在其设备上查看内容,但有时将屏幕显示给某人看并不足以分享信息。通过打印 Android 应用中的信息,用户可以查看应用内容的较大版本,或者与未使用您的应用的其他人分享这些信息。
此外,用户还可以通过打印功能创建信息的快照,而这些快照无需考虑拥有设备、电池电量是否充足或是否具有无线网络连接。
在 Android 4.4(API 级别 19)及更高版本中,框架提供直接从 Android 应用打印图片和文档的服务。此培训介绍如何在应用中启用打印功能,包括打印图片、HTML 页面以及创建要打印的自定义文档。
课程
-
打印照片
- 这节课介绍如何打印图片。
-
打印 HTML 文档
- 这节课介绍如何打印 HTML 文档。
-
打印自定义文档
- 本课介绍如何连接到 Android 打印管理器、创建打印适配器以及构建要打印的内容。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Printing files\n\nAndroid users frequently view content solely on their devices, but there are times when\nshowing someone a screen is not an adequate way to share information. Being able to print\ninformation from your Android application gives users a way to see a larger version of the\ncontent from your app or share it with another person who is not using your application.\nPrinting also allows them to create a snapshot of information that does not depend on having a\ndevice, sufficient battery power, or a wireless network connection.\n\n\nIn Android 4.4 (API level 19) and higher, the framework provides services for printing images and\ndocuments directly from Android applications. This training describes how to enable printing in\nyour application, including printing images, HTML pages and creating custom documents for\nprinting.\n\nLessons\n-------\n\n\n**[Printing a photo](/training/printing/photos)**\n: This lesson shows you how to print an image.\n\n\n**[Printing an HTML document](/training/printing/html-docs)**\n: This lesson shows you how to print an HTML document.\n\n\n**[Printing a custom document](/training/printing/custom-docs)**\n: This lesson shows you how you connect to the Android print manager, create a print adapter\n and build content for printing."]]