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

不知道您是否想通,但这可能会有所帮助:

将 android:largeHeap="true" 添加到您的 Mainfest。

就像是...

<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 回答