谁能指导我如何从android浏览器启动我的android应用程序?


当前回答

截至2014年1月28日,以上所有答案都不适合我使用CHROME

我的应用程序正确启动从http://example.com/someresource/链接从应用程序,如hangouts, gmail等,但不是从chrome浏览器。

为了解决这个问题,让它从CHROME正确启动,你必须像这样设置意图过滤器

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
    <data
        android:host="www.example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
</intent-filter>

注意pathPrefix元素

您的应用程序现在将出现在活动选择器内,每当用户请求http://example.com/someresource/模式从chrome浏览器点击谷歌搜索结果或任何其他网站的链接

其他回答

下面的链接给出了直接从浏览器启动应用程序(如果已安装)的信息。否则它会直接在游戏商店中打开应用程序,以便用户可以无缝下载。

https://developer.chrome.com/multidevice/android/intents

你需要添加一个伪主机名到CALLBACK_URL 'app://'作为URL没有意义,不能被解析。

嘿,我有办法了。我没有将类别设置为“默认”。此外,我使用的主要活动的意图数据。现在我正在使用一个不同的活动的意图数据。谢谢你的帮助。:)

截至2019年6月15日

我所做的是包括所有四种打开url的可能性。

也就是说,有HTTP / HTTPS, 2有WWW前缀,2没有WWW

通过使用这个,我的应用程序现在自动启动,而不需要我选择浏览器和其他选项。

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="https" android:host="example.in" />
    <data android:scheme="https" android:host="www.example.in" />
    <data android:scheme="http" android:host="example.in" />
    <data android:scheme="http" android:host="www.example.in" />

</intent-filter>

截至2014年1月28日,以上所有答案都不适合我使用CHROME

我的应用程序正确启动从http://example.com/someresource/链接从应用程序,如hangouts, gmail等,但不是从chrome浏览器。

为了解决这个问题,让它从CHROME正确启动,你必须像这样设置意图过滤器

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
    <data
        android:host="www.example.com"
        android:pathPrefix="/someresource/"
        android:scheme="http" />
</intent-filter>

注意pathPrefix元素

您的应用程序现在将出现在活动选择器内,每当用户请求http://example.com/someresource/模式从chrome浏览器点击谷歌搜索结果或任何其他网站的链接