title: How to print image displayed in ImageView in android Studio
body: <p>I have a recyclerView which will display all images from JSON path and I used a click event that will display the clicked image to a new activity. </p>
  
  <p>Now I want to print the image that is displayed. I have put a print button in the activity and while clicking on the print button i should get image to be printed in the network printer. I have used the below code. but I am getting error in <code>getActivity()</code> . </p>
  
  <pre><code>Button print = findViewById(R.id.print);
          //imageView.setDrawingCacheEnabled( true );
  
  
          print.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  PrintHelper photoPrinter = new PrintHelper(getActivity());
                  photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
                  //Bitmap bitmap = imageView.getDrawingCache(  );
                  Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
                  photoPrinter.printBitmap("test print",bitmap);
              }
          });
  </code></pre>
  
  <p>Any help will be greatly appreciated :)</p>