summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/Activity.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/app/Activity.java')
-rw-r--r--core/java/android/app/Activity.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 90567c7..2a76a19 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4279,6 +4279,10 @@ public class Activity extends ContextThemeWrapper
if (mParent == null) {
int result = ActivityManager.START_RETURN_INTENT_TO_CALLER;
try {
+ Uri referrer = onProvideReferrer();
+ if (referrer != null) {
+ intent.putExtra(Intent.EXTRA_REFERRER, referrer);
+ }
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess();
result = ActivityManagerNative.getDefault()
@@ -4463,6 +4467,10 @@ public class Activity extends ContextThemeWrapper
@Override
public void startActivityForResult(
String who, Intent intent, int requestCode, @Nullable Bundle options) {
+ Uri referrer = onProvideReferrer();
+ if (referrer != null) {
+ intent.putExtra(Intent.EXTRA_REFERRER, referrer);
+ }
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, who,
@@ -4616,6 +4624,16 @@ public class Activity extends ContextThemeWrapper
}
/**
+ * Override to generate the desired referrer for the content currently being shown
+ * by the app. The default implementation returns null, meaning the referrer will simply
+ * be the android-app: of the package name of this activity. Return a non-null Uri to
+ * have that supplied as the {@link Intent#EXTRA_REFERRER} of any activities started from it.
+ */
+ public Uri onProvideReferrer() {
+ return null;
+ }
+
+ /**
* Return the name of the package that invoked this activity. This is who
* the data in {@link #setResult setResult()} will be sent to. You can
* use this information to validate that the recipient is allowed to