ylliX - Online Advertising Network
Alfredo Hernández (AlfredoHdez1709)

EasyCameraAndGallery | Android-Arsenal.com


Get Permission Home Camera Select photo Send result

Install

Support API 21 and above

Step 1. Add it in your root build.gradle at the end of repositories:

maven { url 'https://jitpack.io' }

Step 2. Add the dependency

implementation 'com.github.AlfredoHdez1709:EasyCameraAndGallery:{version}'

Basic implementation

Generate call result from an activity

returns a list with paths of captured or selected images (List)

    private lateinit var resultScan: ActivityResultLauncher<Intent>

    private fun initCall() {
        resultScan = registerForActivityResult(androidx.activity.result.contract.
        ActivityResultContracts.StartActivityForResult()) { result ->
                if (result.resultCode == Activity.RESULT_OK) {
                    val list = result.data?.getStringArrayListExtra(EasyCamera.IMAGE_RESULTS)
                    print(list)
                }
            }
    }

Launch the camera send as parameter the context, options and result

EasyCamera.start(this, OptionsCamera(), resultScan)

Custom implementation

val optionsCamera = OptionsCamera(
            count = 1,
            path = "CustomFolder",
            flash = Flash.Auto,
            isFrontFacing = true,
            ratio = Ratio.RATIO_16_9
        )

EasyCamera.start(this, optionsCamera, resultScan)
Attributes Type Note
count Int Number of captured images.
path String Folder where the images are saved. pictures/customFolder
flash Flash Control the flash of your implementation.
isFrontFacing Boolean Turn on the front camera by default.
ratio Ration Control the dimensions of your captured image.

Thanks to

License

Licensed under MIT, click here for the full license.

Author & support

This project was created by AHRSOFT.

If you appreciate my work, consider buying me a cup of ☕ to keep me recharged ???? by PayPal



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *