Pergunta

I want to print from my android application to the printer I registered with Google cloud print. But every time I tried printing the web page, I always got the document missing error. This is my code but I don't know which line is causing the error.

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);
}

So basically, http://myserver.com/demo/view/myusername is the web page I want to print and text/html is the mime type I provide. Can someone tells me which part of it that causes the error because I tried the URL from my laptop browser and the web page is loaded. Thank you very much. :D

Foi útil?

Solução

Well, I'm not sure what's wrong with my code, and I still haven't got the slightest idea what should the mime type be. So I came up with a solution:

  1. Generate the html file programatically
  2. Print it with "text/html" type

That should get it done. :)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top