Class ScreenRecorder
-
- All Implemented Interfaces:
public final class ScreenRecorder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classScreenRecorder.Companion
-
Field Summary
Fields Modifier and Type Field Description private volatile BooleancontentMayHaveChangedpublic final static ScreenRecorder.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description ScreenRecorder()
-
Method Summary
Modifier and Type Method Description final BooleangetContentMayHaveChanged()final UnitsetContentMayHaveChanged(Boolean contentMayHaveChanged)final ByteArraycaptureScreenshot(View rootView)Captures a screenshot of the provided rootView at 1x scale (logical pixels). final UnitclearBitmapPool()Clears the bitmap pool and releases all pooled bitmaps. -
-
Method Detail
-
getContentMayHaveChanged
final Boolean getContentMayHaveChanged()
-
setContentMayHaveChanged
final Unit setContentMayHaveChanged(Boolean contentMayHaveChanged)
-
captureScreenshot
final ByteArray captureScreenshot(View rootView)
Captures a screenshot of the provided rootView at 1x scale (logical pixels).
This method renders the view hierarchy into a Bitmap at 1x density (similar to iOS scale = 1.0), applies masking if necessary, compresses the image to a JPEG byte array, and then recycles the Bitmap to free memory.
Threading: This function MUST be called from the main thread as it performs view operations. CPU-intensive compression happens on a background thread.
-
clearBitmapPool
final Unit clearBitmapPool()
Clears the bitmap pool and releases all pooled bitmaps.
This should be called when screen recording stops to free memory. The pool will be re-initialized automatically on the next screenshot capture.
Thread-safe: Uses synchronization to prevent race conditions with concurrent screenshot captures or pool initialization.
-
-
-
-