0

I got a function takes screenshot only visible screen, not taking full WebView screenshot.

It does not give hidden or scrolled content, just take snap of current view.

Here is my code.

public File getBitmapFromwebchartView(WebView view2) {

    if (view2 != null) {
        view2.setDrawingCacheEnabled(true);
        Bitmap b = view2.getDrawingCache();
        if (b != null) {

            try {

                //File fi = new File(Environment.getExternalStorageDirectory(), "Screenshot" + ".jpg");
                fi   = new File(Environment.getExternalStorageDirectory(),"Realitycheck" + ".jpg");

                // write the bytes in file
                FileOutputStream fo;

                fo = new FileOutputStream(fi);

                b.compress(CompressFormat.JPEG, 100, fo);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return fi;
}
LF00
  • 27,015
  • 29
  • 156
  • 295
FAAD
  • 79
  • 3
  • 13

1 Answers1

0

TRY:

 Picture picture = view.capturePicture();
                    Bitmap  b = Bitmap.createBitmap( picture.getWidth(),
                    picture.getHeight(), Bitmap.Config.ARGB_8888);
                    Canvas c = new Canvas( b );

                    picture.draw( c );
                    FileOutputStream fos = null;
                    try {

                        fos = new FileOutputStream( "mnt/sdcard/screenshot.jpg" );
                            if ( fos != null )
                            {
                                b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
                                fos.close();
                            }
                        }
                   catch(Exception e) {}
Jinesh Soni
  • 249
  • 2
  • 14