How to print Android activity display using cloud

2019-07-18 02:27发布

问题:

I am trying to implement Google Cloud Print into an app, following the Integration Guide. I'm trying to keep it basic by just printing out google.com. When clicking the print button I created, it brings up the dialog, but I am getting a FileNotFoundException stating

java.io.FileNotFoundException: No content provider: http://www.google.com

If I then select a printer and click print, the dialog gives me a "Document Missing" message, which makes sense based on the FileNotFoundException.

I took print_dialog.xml and PrintDialogActivity.java verbatim from the guide. Here is my code calling the activity:

Intent printIntent = new Intent(getActivity(), PrintDialogActivity.class);
Uri docUri = Uri.parse("http://www.google.com");
printIntent.setDataAndType(docUri, "text/html");
printIntent.putExtra("title", "Google");
startActivity(printIntent);

I'm attempting to figure out how to print a web page, but would eventually like to be able to print the activity display.

So my question is: What do I need to do in order to print a webpage or activity display?

回答1:

Try to add the following to your application manifest

<uses-permission android:name="android.permission.INTERNET" />