April 25, 2024, 12:11 p.m. | Mobile innovation Network

DEV Community dev.to

ScreenCapture is a Compose Multiplatform library for capturing screens in your Android or iOS App.






Installation


Add the dependency to your build.gradle.kts file:



commonMain.dependencies {
implementation("network.chaintech:compose-multiplatform-screen-capture:1.0.1")
}





Usage


Android



  • Include this in your AndroidManifest.xml:



<provider
android:name="androidx.core.content.FileProvider"
android:authorities="network.chaintech.cmp.screenshot.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>



  • Create file_paths.xml in androidMain->res->xml and add the following code:



<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path
name="screen_shots"
path="share_images" />
<external-path
name="external_files"
path="." />
</paths>



  • Add the following line in onCreate of your Activity class:



class AppActivity : ComponentActivity() {
override …

android app build code composemultiplatform core create data dependencies false file files gradle implementation installation ios library meta network path provider screencapture support true usage xml

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne