1

我试图在我的网页加载后使用 javascript 打开我的 android 应用程序。我在stackoverflow上看到了很多答案,但似乎没有一个对我有用。

镀铬 | 默认移动浏览器我的链接看起来像:

<a href="myappschema://myapphost/" id="deeplink" > return back to my app </a>

当用户点击链接时,这工作正常,但我如何在页面加载后从 javascript 调用它?

我尝试使用 jquery 和 javascript,如下所示,但没有成功。有什么帮助吗?

1-

 window.location.href = "myappschema://myapphost/";

2-

 setTimeout(function () {
                  jQuery('#deeplink')[0].click();
                    }, 3000);

在我的活动中,我添加了:

  [Activity(Label = "@string/app_name", MainLauncher = true,
            WindowSoftInputMode = SoftInput.AdjustResize,
            Icon = "@mipmap/ic_logo_2", Theme = "@style/MyTheme.Splash")]
        [IntentFilter(new[] { Android.Content.Intent.ActionView,Android.Content.Intent.CategoryBrowsable,Android.Content.Intent.ActionDefault },
        DataScheme = "myappschema",
        DataHost = "myapphost",
        DataPathPrefix = "/",
        Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable,Android.Content.Intent.ActionDefault })]
   public class MainActivity : AppCompatActivity, NavigationView.IOnNavigationItemSelectedListener
    {}
4

0 回答 0