【问题标题】:How to open android application from a webpage?如何从网页打开android应用程序?
【发布时间】:2015-07-14 10:41:40
【问题描述】:

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

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

安卓代码:

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

在我的网站上做了一些事情后,我想再次打开我的安卓应用。

我找到了这段代码,

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

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

【问题讨论】:

  • Android 的“返回”按钮不会让用户返回您的应用吗?如果您想要更多控制权,您可以随时让用户在您的应用程序内浏览 Android 的 WebView 内的网页。在这种情况下,可以通过完成 WebView 活动来实现返回。不过,我无法对 iOS 发表评论。

标签: javascript android html ios web


【解决方案1】:

你可以看看这个: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">

【讨论】:

    【解决方案2】:

    对于 iOS,您可以设置 URLSchemes,如果在浏览器上键入将启动应用程序:例如,如果您的应用程序名为 market

    market:// 将启动应用程序

    在信息标签中添加 URLScheme :

    您可以通过实现来处理 url 选项 application:willFinishLaunchingWithOptions:application:didFinishLaunchingWithOptions: 方法。

    【讨论】:

      【解决方案3】:

      无法再启动 Android Chrome 25 link

      对于 iOS,您可以阅读 this question

      【讨论】:

        【解决方案4】:

        您可以通过在网站中添加一个小脚本和对代码进行一些更改来实现它。你必须制定 url 方案。

        【讨论】:

          猜你喜欢
          • 2023-02-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-09-18
          • 2010-10-04
          • 2015-04-01
          相关资源
          最近更新 更多