0

In my Application, I can only capture VISIBLE regions but Scrolling regions are not displaying in Captured Image. For it I did,

private void saveBitmap(Bitmap bitmap) {
    shopPath = new File(Environment.getExternalStorageDirectory() + "/Shopping_List.png");
    FileOutputStream fos;
    try {
        fos = new FileOutputStream(shopPath);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
        fos.flush();
        fos.close();
    } catch (FileNotFoundException e) {
        Log.e("FileException", e.getMessage(), e);
    } catch (IOException e) {
        Log.e("InputException", e.getMessage(), e);
    }
}


 private Bitmap takeScreenshot() {
    View rootView = findViewById(android.R.id.content).getRootView();
    rootView.setDrawingCacheEnabled(true);
    return rootView.getDrawingCache();
}

It only taking VISIBLE shot but not Full activity.. which are beyond the screen.. Please Help me.. Thank you in Advance.

  • Possible duplicate of answered question http://stackoverflow.com/questions/9791714/take-a-screenshot-of-a-whole-view – Gero Apr 20 '15 at 13:34
  • thnxx gero for quick response but let me know in easy manner to capture entire screen even beyond the screen records also... – Ahana Srivastava Apr 20 '15 at 13:37
  • just copypaste loadBitmapFromView method and call saveBitmap(loadBitmapFromView(rootView,rootView.getWidth(),rootView.getHeight())) – Gero Apr 20 '15 at 13:40
  • Do you need to take inside your application? Or you need to take a screenshot using adb? http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html – Viktor Yakunin Apr 20 '15 at 13:41
  • Hi Gero... what is loadBitmapFromView ? should i create this method ? anyways, your answer is staright forward... wooow – Ahana Srivastava Apr 20 '15 at 13:44
  • Hi Victor... I have to create screenshot when i press button not by adb – Ahana Srivastava Apr 20 '15 at 13:45
  • possible duplicate of [How to programatically take a screenshot on Android?](http://stackoverflow.com/questions/2661536/how-to-programatically-take-a-screenshot-on-android) – Viktor Yakunin Apr 20 '15 at 14:11

1 Answers1

-1
             view.measure(MeasureSpec.makeMeasureSpec(
                    MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED),
                    MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
            view.layout(0, 0, view.getMeasuredWidth(),
                    view.getMeasuredHeight());
            view.setDrawingCacheEnabled(true);
            view.buildDrawingCache();
            Bitmap bm = Bitmap.createBitmap(view.getMeasuredWidth(),
                    webView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);

            Canvas bigcanvas = new Canvas(bm);
            view.draw(bigcanvas);

I Just Tried this it works... its not the same code but you get the idea.. oyu can now use the bitmap!!

BSathvik
  • 95
  • 1
  • 6