I am working on an android application that needs to print to a printer. I decided on using the Google Cloud Print, as it seemed easy to set up. Initially, I followed the steps found here for integrating into Android. This works, as in it will print to my desired printer. However, this process is a bit involved for the user. In my case, the process is as follows:
- The user selects the print button that I have displayed next to some information.
- A Dialog is shown with a preview of what will be printed. There is a button in the ActionBar that says "Print". This begins the process.
- A new Activity is displayed showing a list of printers that are connected to that users Google Account. The user must select one.
- A new page is shown giving a description of the print job.
- The user has to select "Print" in the upper right hand corner.
- The print job is started and the printer prints out the picture.
Unfortunately, my client does not want this process. They want the user to click "Print" in step two, and then have the picture printed (steps 1, 2 and 6). Thus, I cannot use Intent provided by Google, I must use the actual API. This requires me to get a Google Auth token, get the desired printer, and submit a print job that way. I do the following:
- Use the Google Play Services to retrieve an OAuth token for the users Gmail account.
- Get a list of printers using the /search API call.
- Submit a print job using the /submit API call.
I have the first two finished. I am just having trouble with the actual printing of the picture. Instead of printing the picture, the byte data of the picture is being printed (Base64 encoded). Here is some code as to how I am sending up the request:
ContentResolver contentResolver = context.getContentResolver();
try {
Inp