Crop intent¶
Quick start¶
You can choose the following three ways to call the cropping application. The main differences are as follows:
- If you use
VastCropActivity
, the cropping application built based on CropViewLayout will be used. - If you use
CropIntent
, you need to obtain theUri
of the returned image and refer to Uri permissions to revoke permissions. - If you use
CropIntent
andCropPhotoContract
, there is no need to set theUri
of the returned image and revoke permissions.
graph LR
A[Cropping]-->B[VastCropActivity]
A-->C[CropIntent]
A-->D[CropIntent with CropPhotoContract]
You can refer to Sample code to see a complete usage example.
Set output picture name¶
Call setOutputName
to set output picture name,or take value as the default value.
val cropIntent = CropIntent()
... // Other setting
.setOutputName("Name defined by yourself.")
.getIntent()
Uri permission¶
Uri permission
Because permission is granted to the specified uri in setOutputUri
, you need to call Context.revokeUriPermission
at the appropriate moment to cancel it. This operation is to solve the problem that the mobile phone shows that the photo saving fails. This is not required if using CropPhotoContract
.
// Cancel permission of outputUri
ContextHelper.getAppContext()
.revokeUriPermission(outputUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION)