I try to create a simple web browser. I need help to create a tabs activity.
How to show a preview of web-view? Is this preview is an image?
I take a bitmap from web-view in this way:
Thread {
if (binding.webviewMain.width > 0 && binding.webviewMain.height > 0) {
val bitmap = GlideBitmapPool.getBitmap(
binding.webviewMain.width,
binding.webviewMain.width,
Bitmap.Config.RGB_565)
val canvas = Canvas(bitmap)
binding.webviewMain.draw(canvas)
if (!directoryTabs.exists())
directoryTabs.mkdir()
val fName = "IMG_${positionPage}_tabs.JPEG"
val file = File(directoryTabs, fName)
try {
val fos = FileOutputStream(file)
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos)
fos.flush()
fos.close()
} catch (e: Exception) {
e.stackTrace
}
//Recycler Bitmap
GlideBitmapPool.putBitmap(bitmap)
}
}.start()
But, Is this way is correct? Thank you for helping me.
