Android Print Intent

13,560 views

Published on

Some printer vendors make photo printing application freely available in Google’s Android Marketplace. Those applications allow printing of photos from an Android phone to a nearby printer and currently, only photos stored in the Android Gallery (a folder on the SDCard) can be printed. However, there are many great Android applications available that work with photos that are not kept in the Android Gallery, e.g. Flickr or Picasa Photo viewing application, gathering content from the cloud.

Android’s open architectures allows applications to temporarily transfer control to other installed applications, to perform certain tasks. I’m going to show how to enable printing in your Android applications, by re-using intents, implemented in other apps. If such intents can be found on a device, we will programmatically walk the user through its installation process, which would happen through the Android Marketplace.

Published in: Technology, Business
1 Comment
3 Likes
Statistics
Notes
  • Thanks sir. its good working...
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
13,560
On SlideShare
0
From Embeds
0
Number of Embeds
4,243
Actions
Shares
0
Downloads
94
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide

Android Print Intent

  1. 1. ANDROIDapplication fundamentals: Intents & Printing on© Copyright 2011 Wolf Paulus
  2. 2. agenda•Cloud Printing•Local Wifi printing from Android•Enable Printing in your Android Application•Writing a cool FingerPaint app that prints your Artwork to photo paper2 © Copyright 2011 Wolf Paulus
  3. 3. Vendor Proprietary Solution Print Configuration Page, showing printer’s email address Register printer at http://www.hp.com/go/eprintcenter Send email to the printer’s email address to get attachments printed© Copyright 2011 Wolf Paulus
  4. 4. Vendor Proprietary Solution© Copyright 2011 Wolf Paulus
  5. 5. Vendor Proprietary Solution© Copyright 2011 Wolf Paulus
  6. 6. Vendor Proprietary Solution .... when used on an Android Phone© Copyright 2011 Wolf Paulus
  7. 7. Android Browser App: http://mail.google.com© Copyright 2011 Wolf Paulus
  8. 8. Android Gmail App © Copyright 2011 Wolf Paulus
  9. 9. Forward to ePrinter’s email address: s ent cum 84 Do uri ty 1 599....@hpeprint.com and Sec 472 ses ass Pas ng gP di S tB o ar AS RR es -P r in ar din DIN GP est Ai r lin s Bo BO AR ard ing Bo roup line thw Sou F G st Air OL uth we S/W So LU AUT 01 on siti Po P H 6 da t G nte FLI JX Pri MA Y 17 WO Q3 :30 AM B orm a tio n : Q DIEGOSE 08 nt Inf P NR N JSA AN ort a -- 601 to S Imp -- er -- Oth - -- nd -- sa -- tice -- No -- - -- -- -- R E- E DH OL - -F -- -- - -- -- -- 66 - -- -- -- - -- -- 9 © Copyright 2011 Wolf Paulus
  10. 10. Google’s cloud print solution© Copyright 2011 Wolf Paulus
  11. 11. Google’s cloud print solution Install the Google Chrome Web Browser on a PC/Mac that is on the printer’s LAN Open Chrome’s “Preferences / Under the Hood” page Click “Sign in to Google Cloud Print Button” on the very bottom of the page Sign-in with your Google / Gmail credentials All the Printer’s known to the registering PC/Mac are now available.© Copyright 2011 Wolf Paulus
  12. 12. © Copyright 2011 Wolf Paulus
  13. 13. © Copyright 2011 Wolf Paulus
  14. 14. Google’s cloud print solution .... when used on an Android Phone© Copyright 2011 Wolf Paulus
  15. 15. © Copyright 2011 Wolf Paulus
  16. 16. Best of both Worlds: http://www.google.com/landing/cloudprint/hp-enable.html© Copyright 2011 Wolf Paulus
  17. 17. http://www.google.com/webelements/#!/cloudprint<script src="//www.google.com/cloudprint/client/cpgadget.js"/><script defer="defer"> var gadget = new cloudprint.Gadget(); gadget.setPrintButton( cloudprint.Gadget.createDefaultPrintButton("default_print_button_container")); gadget.setPrintDocument("url", "Cloud Print test page", "http://www.google.com/landing/cloudprint/testpage.pdf");</script> © Copyright 2011 Wolf Paulus
  18. 18. agenda•Cloud Printing•Local Wifi printing from Android•Enable Printing in your Android Application•Writing a cool FingerPaint app that prints your Artwork to photo paper18 © Copyright 2011 Wolf Paulus
  19. 19. 19 © Copyright 2011 Wolf Paulus
  20. 20. Scan to install20 © Copyright 2011 Wolf Paulus
  21. 21. agenda•Cloud Printing•Local Wifi printing from Android•Enable Printing in your Android Application•Writing a cool FingerPaint app that prints your Artwork to photo paper21 © Copyright 2011 Wolf Paulus
  22. 22. android Print IntentIntent intent = new Intent(“org.androidprinting.intent.action.PRINT”);intent.addCategory(Intent.CATEGORY_DEFAULT);intent.setDataAndType(mUri, "application/pdf"); // printable contentstartActivityForResult(intent, REQUEST_CODE_PRINT_FILE); 22 © Copyright 2011 Wolf Paulus
  23. 23. 23 © Copyright 2011 Wolf Paulus
  24. 24. add Printing to your application1. Check that Print-Intent can be handledIf not, programmatically download HP iPrint Photo from Google Marketplace2. Create Print Intent3. Create Image Uri4. Call startActivity() or startActivityForResult() w/ created Intent24 © Copyright 2011 Wolf Paulus
  25. 25. is Intent available0 < getPackageManager().queryIntentActivities(intent, 0).size(); 25 © Copyright 2011 Wolf Paulus
  26. 26. install apkint REQUEST_CODE = 1001;Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=com.hp.android.print"));startActivityForResult(intent, REQUEST_CODE); 26 © Copyright 2011 Wolf Paulus
  27. 27. printingIntent intent= new Intent("org.androidprinting.intent.action.PRINT");intent.addCategory(Intent.CATEGORY_DEFAULT);intent.setDataAndType(saveBitmap(mView.mBitmap), "image/*");startActivity(intent); 27 © Copyright 2011 Wolf Paulus
  28. 28. code + demo© Copyright 2011 Wolf Paulus
  29. 29. agenda•Cloud Printing•Local Wifi printing from Android•Enable Printing in your Android Application•Writing a cool FingerPaint app that prints your Artwork to photo paper29 © Copyright 2011 Wolf Paulus
  30. 30. code + demo© Copyright 2011 Wolf Paulus
  31. 31. Summary •Cloud Printing .. Google Cloud / HP Cloud / Best of Both Worlds •Local WiFi printing from Android w/ HP iPrint Photo •Enable Printing in your Android Application in four easy steps31 © Copyright 2011 Wolf Paulus
  32. 32. 32 © Copyright 2011 Wolf Paulus
  33. 33. Thanks for Coming33 © Copyright 2011 Wolf Paulus

×