如何使用自定义网址方案启动android应用 [英] how to launch an android app with custom url scheme
本文介绍了如何使用自定义网址方案启动android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从自定义URL方案启动我的应用程序.我检查了开发android上的深层链接"部分,这是我的代码段.不过,使用似乎如下的URL似乎不会触发:myApp://?host = myhost.com
I want to launch my app from a custom URL scheme. I checked the deep links section on dev android and here is a snippet of my code. This doesnt seem to fire though with a URL that looks like : myApp://?host=myhost.com
清单:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myApp" />
</intent-filter>
在我主要的活动中,我有:
In the activity which is my main activity, i have :
Intent intent = getIntent();
Uri uri = intent.getData();
if (uri != null) {
String host = uri.getQueryParameter("host");
}
当我有以URL作为超链接的电子邮件时,该应用程序无法启动.另外,什么是测试此内容的好方法?
The app does not launch when i have email that has the url as a hyperlink. Also, what would be a good way to test this ?
推荐答案
浏览器将方案转换为小写,因此您需要将数据标签更改为
The browser converts the scheme to lowercase, so you need to change the data tag to
<data android:scheme="myapp"/>
这篇关于如何使用自定义网址方案启动android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文