Bypassing dialog box or Silent print

1.8k views Asked by At

How to bypass printer dialog box in android application ? I have already tried the PRINTER API from android but it prompts me a preview box Checked many things then found it is possible through google cloud print but not sure if anyone an confirm and guide the same. Will be really greatful thanks in advance

1

There are 1 answers

2
jmrodrigg On

As far as I know, the documentation on https://developers.google.com/cloud-print/docs/android explains two possible options to integrate GCP functionality in your app:

  • For 4.3 devices and below, it depicts how to display the GCP web element (described in section GCP Web Element).
  • For 4.4 devices and above, since the Android.Print API is included, they redirect you to the Android's documentation on how to implement printing functionality in your app.

Using the Android.Print API will always result in a call to the OS Print Dialog, where you will be prompted to select the printer from the list and the print settings. In this case, the list of printers is provided by the different print services the user has installed in their device, and Google Cloud Print is one of them.

Having said that, there's still a way to achieve what you call silent print. You may need to implement the Google Cloud Print API calls in your own application. I've done it as part of a Java applicatio, so it won't be very different in Android.It requires 2 things:

  • Implement OAuth2 in order to get the google user's authorization token. API calls must contain a valid Authorization HTTP header. Also, this is required because the API calls will respond based on the printers the user has access to.
  • Implement the API calls that you need to select the printer (/search) and submit the job (/submit). You may also need to check printer capabilities and status (/printer).

You'll find all the required info on https://developers.google.com/cloud-print/docs/appInterfaces

More information on OAuth 2.0 to access Google APIs on https://developers.google.com/identity/protocols/OAuth2