android.support.v4.print.PrintHelper Java Examples

The following examples show how to use android.support.v4.print.PrintHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemActivity.java    From Camera-Roll-Android-App with Apache License 2.0 7 votes vote down vote up
public void printPhoto() {
    if (!(albumItem instanceof Photo)) {
        Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
        return;
    }

    PrintHelper photoPrinter = new PrintHelper(this);
    photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
    try {
        photoPrinter.printBitmap(albumItem.getPath(),
                albumItem.getUri(this));
    } catch (FileNotFoundException e) {
        Toast.makeText(this, "Error (FileNotFoundException)", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
}
 
Example #2
Source File: DoodleView.java    From CSCI4669-Fall15-Android with Apache License 2.0 6 votes vote down vote up
public void printImage()
{
   if (PrintHelper.systemSupportsPrint())
   {
      // use Android Support Library's PrintHelper to print image
      PrintHelper printHelper = new PrintHelper(getContext());
      
      // fit image in page bounds and print the image
      printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
      printHelper.printBitmap("Doodlz Image", bitmap); 
   }
   else
   {
      // display message indicating that system does not allow printing
      Toast message = Toast.makeText(getContext(), 
         R.string.message_error_printing, Toast.LENGTH_SHORT);
      message.setGravity(Gravity.CENTER, message.getXOffset() / 2, 
         message.getYOffset() / 2);
      message.show(); 
   }
}
 
Example #3
Source File: DoodleView.java    From CSCI4669-Fall15-Android with Apache License 2.0 6 votes vote down vote up
public void printImage()
{
   if (PrintHelper.systemSupportsPrint())
   {
      // use Android Support Library's PrintHelper to print image
      PrintHelper printHelper = new PrintHelper(getContext());
      
      // fit image in page bounds and print the image
      printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
      printHelper.printBitmap("Doodlz Image", bitmap); 
   }
   else
   {
      // display message indicating that system does not allow printing
      Toast message = Toast.makeText(getContext(), 
         R.string.message_error_printing, Toast.LENGTH_SHORT);
      message.setGravity(Gravity.CENTER, message.getXOffset() / 2, 
         message.getYOffset() / 2);
      message.show(); 
   }
}
 
Example #4
Source File: PrintHelperAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public PrintHelperAssert(PrintHelper actual) {
  super(actual, PrintHelperAssert.class);
}