【问题标题】:Android: How to print an HTML page directly on Samsung Mobile PrintAndroid:如何在 Samsung Mobile Print 上直接打印 HTML 页面
【发布时间】:2013-10-20 07:09:18
【问题描述】:

我正在开发一个 Android 应用程序,我想通过 Samsung Mobile Print 应用程序打印一个 HTML 页面。我需要这样做的意图参数是什么,即

  • 包名

  • MIME 类型

  • 操作类型(ACTION_SENDACTION_VIEW 等)

  • 所需的任何其他参数。

有没有办法找出这些参数?我设法使用 adb shell 找到了包名称,但是当我尝试将 HTML 页面作为包传递时,它会抛出一个 ActivityNotFoundException (No Activity found to handle ACTION_SEND)

我知道还有其他打印选项,例如 PrinterShare Pro 和 Gooble Cloud Print,但我正在为客户开发此应用程序,因此我必须与 Samsung Mobile Print 应用程序通信。

感谢您的帮助。

【问题讨论】:

    标签: android android-intent printing samsung-mobile


    【解决方案1】:

    我联系了 Samsung Mobile Print 应用程序的开发人员,他们提供了以下代码:

    Intent intent = new Intent("com.sec.print.mobileprint.action.PRINT");
    Uri uri = Uri.parse("http://www.samsung.com");
    intent.putExtra("com.sec.print.mobileprint.extra.CONTENT", uri );
    intent.putExtra("com.sec.print.mobileprint.extra.CONTENT_TYPE", "WEBPAGE");
    intent.putExtra("com.sec.print.mobileprint.extra.OPTION_TYPE", "DOCUMENT_PRINT");
    intent.putExtra("com.sec.print.mobileprint.extra.JOB_NAME", "Untitled");
    startActivity(intent);
    

    【讨论】:

    • 能否提供您在上述详细信息中找到的链接?
    • 如果您要打印本地 HTML 文件,请确保将您的 URI 写为“file:///pathtoyourfile/yourfile.html”,否则 Samsung Mobile Print 将打开您的路径作为 Google 查询。
    猜你喜欢
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    相关资源
    最近更新 更多