我正在尝试在用户访问网站时从浏览器启动活动(仅显示警告图标)但是当我将意图过滤器添加到我的AndroidManifest.xml时,应用程序在加载时不会启动新活动URL。
它加载的唯一方法是,如果它是指向网址的链接(例如在电子邮件中),而不是在用户实际提起网址时播放www.playboy.com
有什么建议吗?
清单
<activity
android:name="com.app.Warning"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="playboy.com" android:scheme="http"></data>
</intent-filter>
</activity>
答案 0 :(得分:1)
如有疑问,请复制Google。 Play商店和YouTube应用都在其intent-filters中使用某种路径规范。尝试类似pathPrefix="/"
的内容。
Google Play商店的清单包含以下行:
<data android:scheme="http" android:host="market.android.com" android:pathPrefix="/" />
答案 1 :(得分:0)
尝试不使用“www”:
<data android:host="playboy.com" android:scheme="http"></data>
并检查您的浏览器是否设置为此主机的默认应用程序。
您的实施仍然存在一个问题:当它运行时,当用户在playboy.com上冲浪时,Android将显示选择器对话框,要求用户使用您的应用程序的浏览器打开此地址。只有当用户点击你的应用程序时,它才会启动,否则它将像现在一样在浏览器中继续。我不认为这是你想要实现的行为。