点击网站上的按钮是否可以启动android应用

时间:2019-07-09 16:13:06

标签: javascript android

我正在建立一个供我自己使用的网站,并且想知道是否可以通过在手机上的浏览器中打开该网站上的一个按钮来启动特定的android应用。

1 个答案:

答案 0 :(得分:0)

除非您知道该应用程序的方案,否则您无法打开任何应用程序。

要了解有关深层链接的更多信息,请查看此内容。 https://developer.android.com/training/app-links/deep-linking

这来自Android文档。


它的工作方式非常简单。在Android应用程序中,您需要应用...

<activity
    android:name="com.example.android.GizmosActivity"
    android:label="@string/title_gizmos" >
    <intent-filter android:label="@string/filter_view_http_gizmos">
        <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-->
    </intent-filter>
    <intent-filter android:label="@string/filter_view_example_gizmos">
        <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 "example://gizmos” -->
        <data android:scheme="example"
              android:host="gizmos" />
    </intent-filter>
</activity>

例如,上面的代码将寻找http以及example的方案

因此链接可以是http://www.gizmos.comexample://gizmos。但是,由于您要打开任何应用程序,因此除非您知道它们的方案和路径,否则这是不可能的。...这不太可能。