Skip to main content

To a Remote URL

Start Editor#

For the sake of this example, we load a photo from the resources into the photo editor.

By default, PhotoEditor SDK exports the photo as a temporary file in the application's cache directory.

Handle Result#

The result from the editor is received in the onActivityResult() method. EditorSDKResult wraps around the intent and provides a convenient API to check the result. The Uri of the exported photo can be accessed via EditorSDKResult.resultUri. Here, we upload the exported photo by launching a coroutine and calling the NetworkUtils.upload() suspend function. While the upload is running, we show a loader and dismiss it when the upload is finished.

class SavePhotoToRemoteURL(private val activity: AppCompatActivity) : Example(activity) {
override fun invoke() {
// In this example, we do not need access to the Uri(s) after the editor is closed
// so we pass false in the constructor
val settingsList = PhotoEditorSettingsList(false)
// Set the source as the Uri of the image to be loaded
.configure<LoadSettings> {
it.source = activity.resourceUri(
// Start the photo editor using PhotoEditorBuilder
// The result will be obtained in onActivityResult() corresponding to EDITOR_REQUEST_CODE
.startActivityForResult(activity, EDITOR_REQUEST_CODE)
// Release the SettingsList once done
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
super.onActivityResult(requestCode, resultCode, intent)
intent ?: return
if (requestCode == EDITOR_REQUEST_CODE) {
val result = EditorSDKResult(intent)
when (result.resultStatus) {
EditorSDKResult.Status.CANCELED -> showMessage("Editor cancelled")
EditorSDKResult.Status.EXPORT_DONE -> {
// Launch a Coroutine to upload the exported photo
activity.lifecycleScope.launch {
val response = runCatching {
upload(result.resultUri!!, activity.contentResolver)
showMessage(if (response) "Uploaded successfully" else "Upload failed")
else -> {