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 core create data dependencies false file files gradle implementation installation ios library meta network path provider support true usage xml

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US

Research Engineer

@ Allora Labs | Remote

Ecosystem Manager

@ Allora Labs | Remote

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US