8

Simple Android App just developed. I have the printing functionality working in android version 4.4 via api google.

Anyway my final purpose is to print automatically to default printer without any ui interface. Print content is simple html. I need some custom code to resolve this issue.

Kind regards Danilo

  • Please clarify your problem and edit your question with the code that you already have written – Alessandro Lai Apr 22 '15 at 15:41
  • 1
    My question is : Can i print a page html on my default printer connected to my device without print dialog..at the moment i don't try any library that can permit ho hide print dialog....there is an APF framework that is expensive for my use.. http://apf.isb-vietnam.com/ – Danilo Pellicano Apr 22 '15 at 16:28
  • post your code please – Heshan Sandeepa Apr 22 '15 at 16:58
  • Did you get anywhere on this? I would think that this would be a common feature on instruments that use embedded Android, as my product does – Robert R Evans Sep 28 '16 at 16:48
  • 1
    This answer may help you: http://stackoverflow.com/questions/24026804/google-cloud-print-from-android-without-dialog/40107636#40107636 – César Muñoz Oct 18 '16 at 14:43

2 Answers2

3

I think, We can't able to hide that Print Dialog, coz, PrintManager class is final. So, We are not allowed to override that.

When you call this print(String, PrintDocumentAdapter, PrintAttributes) from an activity, It starts Print jobs also it will bringing up the system print UI.

If you want an example for Printing a Document you can refer to this Android-wifi-print - GitHub. This is just a prototype for printing a document using wifi printer.

SureshCS50
  • 3,608
  • 1
  • 20
  • 27
1

Luckily I was able to override the method of print of PrintManager, however you cannot continue print or send the job to print without going to the intent command.

PrintJobInfo printJobInfo = bundleResult.getParcelable("android.print.intent.extra.EXTRA_PRINT_JOB");
IntentSender printIntent = bundleResult.getParcelable("android.print.intent.extra.EXTRA_PRINT_DIALOG_INTENT");

Unless if anyone here have an idea or suggestion how to deal with the intent. I can post the code on how I made my own print method of manager if requested, but its gonna be stuck on the printIntent. If we could just solve the printIntent then we might have a solution to this common problem of hiding the print dialog box.

  • The print manager override code would be interesting to look at, but ultimately the cloud print plugin/apk requires that intent. I don't know that there is a way to get around that part of it if you ultimately want to print using the default android system. – Chris Feb 02 '16 at 14:56
  • I am interested in the statement "Luckily I was able override the method of print of PrintManager". You cannot 'extend' a final class, and there is no other way to 'override' a method. Perhaps you wrapped 'PrintManager' in a class? – Robert R Evans Sep 28 '16 at 16:44