gpt4 book ai didi

android - 如何在浏览器 Android 中点击 url 启动应用程序

转载 作者:太空宇宙 更新时间:2023-11-03 13:18:41 25 4
gpt4 key购买 nike

如果应用程序安装在设备上,我必须在浏览器中点击 url 打开(启动)应用程序。

如果应用没有安装,它应该重定向到 google play 商店。

例如.url - http://testurl.com/event?event_code=u322

我正在使用这个代码

 <activity
android:name="com.quantumsolutions.activities.Splashscreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="GiftFund.com"
android:scheme="http" />
<data
android:host="giftfund.com/details?id=123"
android:scheme="http" />
<data
android:host="giftfund.com/event?event_code=PF38A"
android:scheme="http" />
<data
android:host="qa.GiftFund.com"
android:scheme="http" />
<data
android:host="dev.GiftFund.com"
android:scheme="http" />
<data
android:host="giftfund.com"
android:scheme="http" />
<data
android:host="qa.giftfund.com"
android:scheme="http" />
<data
android:host="dev.giftfund.com"
android:scheme="http" />
</intent-filter>
<!--
<intent-filter>
<data android:scheme="giftfund" />

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

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

</activity>

用户可以通过邮件接收此 url,或在 facebook 或短信上发布,但目前如果我通过 gmail 获取 url 而不是单击 url 能够启动应用程序,但是当我单击此 url 时在浏览器或短信中

例如,从 basecamp 或在浏览器中打开的 facebook 帖子,它不会显示我我的应用程序弹出并重新引导我播放商店并显示安装应用程序但应用程序已经安装。

最佳答案

你必须自己制作<intent filter>方案,而是intent filter的顺序元素很重要:

<intent-filter>
<data android:scheme="my_app" />

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

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

如果链接以my_app: 开头您的应用程序将启动。

编辑:

例如将您的方案设置为 my_app并将您的链接修改为my_app://yourlink.com/something摆脱 http .也尝试在您的 Activity 中设置:android:exported="true"

关于android - 如何在浏览器 Android 中点击 url 启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32023130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com