如果网页视图太长,如何获取截图并将其存储在内部存储中。例如,如果我的webview显示"google.com“,我尝试下面的代码,它会截取屏幕截图并将其存储为.jpg。但是如果我的网页显示"stackoverflow.com",因为这个网页太长,应用程序就会崩溃。如果能帮上忙,我们将不胜感激。
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 )
{
}发布于 2013-10-31 13:52:37
不知道你是否想通了,但这可能会有帮助:
将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>https://stackoverflow.com/questions/14483695
复制相似问题