0

How to get screenshot of a webview if it too long and store it in internal storage. So for example if my webview shows "google.com" and i try below code it takes the screenshot and stores it as .jpg. But if my webview shows "stackoverflow.com", as this web page is too long, the app crashes. Some help will be appreciated.

Picture picture=this.getCurrentWebView().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/myjpg.jpg"); 
                    if ( fos != null ){
                        b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
                        fos.close();
                    }
                }
           catch( Exception e )
           {
           }
4

1 に答える 1

0

あなたが理解したかどうかはわかりませんが、これは役立つかもしれません:

Mainfest に android:largeHeap="true" を追加します。

何かのようなもの...

<application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/AppThemeHolo"
        android:largeHeap="true"
        >
...

...
</application>
于 2013-10-31T05:52:37.203 に答える