Improve Intent source app detection
Activity.getReferrer does not only return app IDs but also URLs if Intent.EXTRA_REFERRER is set on the Intent. In the case of Chrome the referrer is set to the website triggering the Intent. To improve the detection of the calling app we check first if the browser specific Browser.EXTRAS_APPLICATION_ID is set. If it is not set we fall back to Intent.getReferrer. Pick-to: 6.6 6.5 Change-Id: I33d1edd52de98486d9616713e531ea20ada87bcb Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
b902b152af
commit
7012bea614
@ -16,6 +16,7 @@ import android.graphics.Canvas;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Browser;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ActionMode;
|
||||
import android.view.ActionMode.Callback;
|
||||
@ -242,10 +243,18 @@ public class QtActivity extends Activity
|
||||
if (intent.getExtras() != null && intent.getExtras().getString(EXTRA_SOURCE_INFO) != null)
|
||||
return;
|
||||
|
||||
String browserApplicationId = "";
|
||||
if (intent.getExtras() != null)
|
||||
browserApplicationId = intent.getExtras().getString(Browser.EXTRA_APPLICATION_ID);
|
||||
|
||||
String sourceInformation = "";
|
||||
if (browserApplicationId != null && !browserApplicationId.isEmpty()) {
|
||||
sourceInformation = browserApplicationId;
|
||||
} else {
|
||||
Uri referrer = getReferrer();
|
||||
if (referrer != null)
|
||||
sourceInformation = referrer.toString().replaceFirst("android-app://", "");
|
||||
}
|
||||
|
||||
intent.putExtra(EXTRA_SOURCE_INFO, sourceInformation);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user