我希望我的应用只能打开一个形式为
的网址http://www.myhost.com/#/followThis/Param1/Param2
这是我的意图
<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="myhost.com" android:scheme="http" android:path="/#/followthis" />
<data android:host="www.myhost.com" android:scheme="http" android:path="/#/followthis" />
</intent-filter>
现在,如果我用任何字母替换#,说&#39; a&#39;它工作正常 我能以任何方式得到这个???
答案 0 :(得分:1)
如果你看看棒棒糖来源,你可以找出这个角色特殊的原因:
// If there isn't any matching ssp, we need to match an authority.
final ArrayList<AuthorityEntry> authorities = mDataAuthorities;
if (authorities != null) {
int authMatch = matchDataAuthority(data);
if (authMatch >= 0) {
final ArrayList<PatternMatcher> paths = mDataPaths;
if (paths == null) {
match = authMatch;
} else if (hasDataPath(data.getPath())) {
match = MATCH_CATEGORY_PATH;
} else {
return NO_MATCH_DATA;
}
} else {
return NO_MATCH_DATA;
}
}
hasDataPath(data.getPath())为false,因为例如&#34; http://myhost.com/#/followthis&#34;构建的Uri的getPath()只是&#34; /&# 34。
这是一个有趣的故事,因为根据RFC,#character之后的部分是FRAGMENT部分,而不是Uri的PATH部分
答案 1 :(得分:0)
尝试:
String query = URLEncoder.encode("apples oranges", "utf-8");
String url = "http://stackoverflow.com/search?q=" + query;