从 JS(网络浏览器)到 android 活动的方案调用不会使用 url 字符串中的方案数据更新意图



我正在从浏览器启动我的应用程序,如果应用程序尚未加载/运行,那么它会通过onCreate启动应用程序并收集intent.data并执行正确的操作。 如果应用程序已经在运行,那么从浏览器启动应用程序会绕过onCreate并直接转到onResume,我"相信"这是预期的行为。 但是与从浏览器启动关联的 intent.data 为空。 我希望意图数据将被方案 url 字符串中的新意图数据覆盖,以便我可以使用新参数重新启动应用程序内的 Web 视图。 有什么方法可以在浏览器启动(即恢复(应用程序时将这些新数据推送到应用程序中?

JS浏览器代码,带有要传递给应用程序的参数。

var r = Math.random();
window.open("myScheme://caca.com/?mode=driver" + "&ec=" + ec + "&uh=" + $("#userHandle").val() + "&at=0" + "&random=" + r);

Xamarin

onResume(...) {
...
try
{
// currentActivity.Intent.Data != null if app is not already running
// is null if already running
Android.Net.Uri data = currentActivity.Intent.Data;
string scheme = data.Scheme;
DebugToast("scheme " + scheme, ToastLength.Long);
if (scheme == "myScheme")
{
// force the cookies so the web app will come up as we specify
SetStorageValue("browserLaunched", "true");
SetStorageValue("mode", data.GetQueryParameter("mode"));
SetStorageValue("ec", data.GetQueryParameter("ec"));
SetStorageValue("uh", data.GetQueryParameter("uh"));
SetStorageValue("authToken", data.GetQueryParameter("at"));
SetStorageValue("at", data.GetQueryParameter("at"));
DebugToast("parms " + data.GetQueryParameter("mode") + " " +  data.GetQueryParameter("ec") + " " + data.GetQueryParameter("uh") + " " +  data.GetQueryParameter("at"), ToastLength.Long);
// restart the web view with arguments above
...
}
}
catch
{
....
}
}

荷马辛普森 D'oh!. 需要将"onNewIntent(("添加到接收"um er dah"新意图并附加适当数据的活动。

最新更新