diff --git a/collect_app/src/main/java/org/odk/collect/android/instancemanagement/send/InstanceUploaderActivity.java b/collect_app/src/main/java/org/odk/collect/android/instancemanagement/send/InstanceUploaderActivity.java index efdf305c2c1..71d3699bf19 100644 --- a/collect_app/src/main/java/org/odk/collect/android/instancemanagement/send/InstanceUploaderActivity.java +++ b/collect_app/src/main/java/org/odk/collect/android/instancemanagement/send/InstanceUploaderActivity.java @@ -20,6 +20,7 @@ import android.app.ProgressDialog; import android.content.DialogInterface; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import org.odk.collect.android.activities.FormFillingActivity; @@ -177,7 +178,7 @@ private void init(Bundle savedInstanceState) { instanceUploaderTask = new InstanceUploaderTask(); if (url != null) { - instanceUploaderTask.setCompleteDestinationUrl(url + OpenRosaConstants.SUBMISSION); + instanceUploaderTask.setCompleteDestinationUrl(url + OpenRosaConstants.SUBMISSION, getReferrerUri(), true); if (deleteInstanceAfterUpload != null) { instanceUploaderTask.setDeleteInstanceAfterSubmission(deleteInstanceAfterUpload); @@ -376,7 +377,7 @@ public void updatedCredentials() { // TODO: is this really needed here? When would the task not have gotten a server set in // init already? if (url != null) { - instanceUploaderTask.setCompleteDestinationUrl(url + OpenRosaConstants.SUBMISSION, false); + instanceUploaderTask.setCompleteDestinationUrl(url + OpenRosaConstants.SUBMISSION, getReferrerUri(), false); } instanceUploaderTask.setRepositories(instancesRepository, formsRepository, settingsProvider); instanceUploaderTask.execute(instancesToSend); @@ -386,4 +387,14 @@ public void updatedCredentials() { public void cancelledUpdatingCredentials() { finish(); } + + private String getReferrerUri() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { + Uri referrerUri = getReferrer(); + if (referrerUri != null) { + return referrerUri.toString(); + } + } + return "unknown"; + } } diff --git a/collect_app/src/main/java/org/odk/collect/android/tasks/InstanceUploaderTask.java b/collect_app/src/main/java/org/odk/collect/android/tasks/InstanceUploaderTask.java index d997a412f0a..b788d041e25 100644 --- a/collect_app/src/main/java/org/odk/collect/android/tasks/InstanceUploaderTask.java +++ b/collect_app/src/main/java/org/odk/collect/android/tasks/InstanceUploaderTask.java @@ -74,6 +74,7 @@ public class InstanceUploaderTask extends AsyncTask