javascript - 如何从网页打开android应用程序?

标签 javascript android html ios web

我可以从 HTML 调用我的应用程序吗?

例如:我可以从我的应用程序正确调用带有此代码的网页。

安卓代码:

  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                                    "myDomain.com")));

在我的网站上做了一些事情之后,我想再次打开我的 Android 应用程序。

我找到这段代码,

<a href="market://details?id=info.androidhive.slidingmenu">

但它只是调用 Market 来查找和安装该应用程序!

最佳答案

你可以看看这个:https://developer.android.com/training/app-indexing/deep-linking.html

<activity
android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_title_viewgizmos">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
    <data android:scheme="http"
          android:host="www.example.com"
          android:pathPrefix="/gizmos" />
    <!-- note that the leading "/" is required for pathPrefix-->
    <!-- Accepts URIs that begin with "example://gizmos”
    <data android:scheme="example"
          android:host="gizmos" />
    -->
</intent-filter>

因此您的应用将通过此链接启动:

<a href="example://gizmos">

关于javascript - 如何从网页打开android应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31404341/

相关文章:

javascript - 获取 Canvas 上下文的最后一个点的坐标

javascript - React setState 改变子进程的 props

javascript - 使用jquery点击多次旋转图像

Java:如何在 RecyclerView Adapter 中设置 ContextCompat 的上下文?

android - RecyclerView 拖放通过 itemTouchHelper 快速拖动时出现异常

html - 如何在同一个 <ul> 父元素的 <li> 中应用不同的样式?

javascript - 使用行类别动态排序 HTML 表

javascript - 使用 content_scripts 修改网页内容

javascript - Google reCaptcha 一直在加载

android - support.v7.app.AlertDialog 在关闭时抛出 NullPointerException