遵循以下建议如何将我的浏览器添加到 Android 的默认浏览器选择列表中? https://stackoverflow.com/questions/7394369/how-to-add-my-browser-in-the-default-browser-selection-list-in-android。我已经指定了我的Intent
in the manifest
file:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
<data android:scheme="https"/>
</intent-filter>
我还添加了权限:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
但我的浏览器仍然没有显示在设置中浏览器类别的默认应用程序选项中。
我是否需要执行其他操作才能让我的应用程序显示在浏览器的默认选项中?
尝试包括<category android:name="android.intent.category.BROWSABLE" />
在您的目标活动中intent-filter
as 开发者文档 https://developer.android.com/reference/android/content/Intent#CATEGORY_BROWSABLE said:
如果用户正在查看网页或电子邮件并单击文本中的链接,则生成的 Intent 执行该链接将需要BROWSABLE
类别,以便只有支持该类别的活动才会被视为可能的行动。
为了使intent-filter
可通过可点击的链接进行访问。如果没有它,单击链接将无法解析到您的应用程序。
<activity ...>
<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:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>
.
附加提示:(如果您想强制您的应用程序成为默认浏览器)
安卓应用程序链接 https://developer.android.com/training/app-links/在 Android 6.0(API 级别 23)及更高版本上,允许应用程序将自身指定为给定类型链接的默认处理程序。如果用户不希望应用程序成为默认处理程序,他们可以从设备的系统设置中覆盖此行为。
要为您的应用程序启用链接处理验证,请设置android:autoVerify="true"
in intent-filter
tag:
<activity ...>
<intent-filter android:autoVerify="true">
...
</intent-filter>
</activity>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)