【问题标题】:launch an installed native android app from a link in a web app从 Web 应用程序中的链接启动已安装的本机 android 应用程序
【发布时间】:2016-04-16 06:47:29
【问题描述】:

我正在尝试使用 Intel XDK 为 Android 手机构建我的第一个网络应用程序。

我已经能够通过链接 (tel:) 和外部网页通过链接 (<a href="#" onclick="openInAppBrowserBlank('http://williamsislandclub.com?userId=1');"><img src="img/wi_app_button_essentials_blue.png"></a>) 成功打开拨号器。

问题:我们社区的大多数手机 (com.app.gateaccess) 上都安装了原生 Android 应用。我想创建一个打开此应用的链接,但找不到我能理解的解决方案。

【问题讨论】:

    标签: android web-applications intel-xdk


    【解决方案1】:

    您必须在应用程序的相应 Activity 标记中将具有自定义方案的意图过滤器添加到清单文件中。格式为:<scheme>://<host>:<port>/<path>

    示例:

    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.BROWSABLE"/>
       <category android:name="android.intent.category.DEFAULT"/>
        <data android:scheme="<PUT SCHEME HERE>" android:host="<PUT URL HERE>" android:path="<PUT PATH HERE>"/>
      </intent-filter>
    

    将此标签替换为 http 或 https 等 url 方案

    将此标签替换为您的网址。 (即 mycoolapps.com)

    用 url 之后的路径替换此标记,即 (/sweetApp)。

    完整示例:

    如果你想用以下网址打开应用程序:

    http://mycoolapps.com/sweetApp

    您的意图过滤器如下所示:

     <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.BROWSABLE"/>
           <category android:name="android.intent.category.DEFAULT"/>
            <data android:scheme="http" android:host="mycoolapps.com" android:path="/sweetApp"/>
          </intent-filter>
    

    【讨论】:

    • 抱歉我的经验不足 - 我可以要求澄清一下吗? (1) 英特尔 XDK 不创建这样命名的清单文件;我将在哪里插入意图? (2) URL 也让我失望 - 如果我的 Android 手机上安装了本机应用程序,我将使用的 url 方案、url 和路径是什么?在 Google Marketplace 中,应用包名称为 com.app.gateaccess
    • 抱歉,我不使用 intel-xdk。我给定的解决方案对于 android 本机应用程序是通用的。这些行需要添加到原生android应用的manifist文件中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-02
    相关资源
    最近更新 更多