我想从我的 Android 应用程序打印到我在 Google 云打印中注册的打印机。但每次我尝试打印网页时,总是出现文档丢失的错误。这是我的代码,但我不知道哪一行导致了错误。
public void print() {
Uri docUri = Uri.parse("http://myserver.com/view/myusername");
String docMimeType = "text/html";
String docTitle = "myTestPage";
Intent printIntent = new Intent(myContext, PrintDialogActivity.class);
printIntent.setDataAndType(docUri, docMimeType);
printIntent.putExtra("title", docTitle);
startActivity(printIntent);
}
基本上,http://myserver.com/demo/view/myusername是我要打印的网页,text/html是我提供的mime类型。有人可以告诉我哪一部分导致了错误,因为我尝试了笔记本电脑浏览器中的 URL 并且加载了网页。非常感谢。 :D
最佳答案
嗯,我不确定我的代码出了什么问题,而且我仍然不知道 mime 类型应该是什么。所以我想出了一个解决方案:
- 以编程方式生成 html 文件
- 使用“text/html”类型打印
这样应该就可以完成了。 :)
关于Android Google 云打印 - 文档丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15049547/