谁能指导我如何从android浏览器启动我的android应用程序?
当前回答
在我的例子中,我必须为<intent-filter>设置两个类别,然后它就工作了:
<intent-filter>
<data android:scheme="my.special.scheme" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
其他回答
你需要添加一个伪主机名到CALLBACK_URL 'app://'作为URL没有意义,不能被解析。
还应该有<category android:name="android.intent.category. browsable "/>添加到intent过滤器中,以便从链接中正确识别活动。
下面的链接给出了直接从浏览器启动应用程序(如果已安装)的信息。否则它会直接在游戏商店中打开应用程序,以便用户可以无缝下载。
https://developer.chrome.com/multidevice/android/intents
Felix处理深度链接的方法是处理深度链接的典型方法。我还建议您查看这个库来处理深层链接的路由和解析:
https://github.com/airbnb/DeepLinkDispatch
您可以使用注释为特定的深链接URI注册Activity,它将为您提取参数,而不必执行获取路径段、匹配它等通常的繁琐操作。你可以像这样简单地注释和活动:
@DeepLink("somePath/{someParameter1}/{someParameter2}")
public class MainActivity extends Activity {
...
}
截至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>
推荐文章
- 改变开关的“开”色
- 以编程方式将EditText的输入类型从PASSWORD更改为NORMAL,反之亦然
- 如何在隐藏和查看密码之间切换
- 在Android上调整一个大的位图文件到缩放输出文件
- 如何更改Android版本和代码版本号?
- Android Studio突然无法解析符号
- 应用程序重新启动而不是恢复
- 如何设置整个应用程序在纵向模式?
- Android中文本的阴影效果?
- 以编程方式设置TextView的布局权重
- Android -如何覆盖“后退”按钮,所以它不完成()我的活动?
- 如何从通知点击发送参数到一个活动?
- 导航目标xxx对于这个NavController是未知的
- 使用ConstraintLayout均匀间距的视图
- 文件google-services错误。模块根文件夹中缺少Json。谷歌服务插件没有它就不能正常工作。