Android <;a>;来自资产文件夹html文件的标记链接
在资产文件夹中的webview html文件中,我只使用facebook id的用户名。这里是包含facebook应用程序和浏览器的固定URL的MainActivity。问题是,当我单击某人的个人资料链接时,会显示:::URL,如下所示Android <;a>;来自资产文件夹html文件的标记链接,android,Android,在资产文件夹中的webview html文件中,我只使用facebook id的用户名。这里是包含facebook应用程序和浏览器的固定URL的MainActivity。问题是,当我单击某人的个人资料链接时,会显示:::URL,如下所示 https://www.facebook.com/file///{FBuserID} fb://profile/file///{FBuserID} 但我需要像这样 https://www.facebook.com/{FBuserID} fb:/
https://www.facebook.com/file///{FBuserID}
fb://profile/file///{FBuserID}
但我需要像这样
https://www.facebook.com/{FBuserID}
fb://profile/{FBuserID}
它来自MainActivity.java(这里是最后一个ELSE中包含的两个固定url
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(intent);
Toast.makeText(getActivity(),(getString(R.string.call_toast)),
Toast.LENGTH_LONG).show();
return true;
} else if (url.startsWith("mailto:")) {
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(url));
startActivity(intent);
Toast.makeText(getActivity(),(getString(R.string.email_toast)),
Toast.LENGTH_LONG).show();
return true;
} else {
if (isAppInstalled(liContext, "com.facebook.orca") || isAppInstalled(liContext, "com.facebook.katana")
|| isAppInstalled(liContext, "com.example.facebook") || isAppInstalled(liContext, "com.facebook.android")) {
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/"+url)));
Toast.makeText(getActivity(),(getString(R.string.facebook_view)),
Toast.LENGTH_LONG).show();
}else{
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/"+url)));
Toast.makeText(getActivity(),(getString(R.string.not_fb)),
Toast.LENGTH_LONG).show();
}
return true;
}
}
});
看起来您的
url
在一开始就包含两个额外的正斜杠。因此,只需删除那些不需要的字符。在一开始,就像(fb://&https://)这些是固定url的一部分。如果我删除它们,则不会指定url。url=固定url新意图的最后一部分(Intent.ACTION\u VIEW,Uri.parse(“fb://profile/”+url));
我说的是“在url的最开始”,意思是变量url
中的字符串以“/”开头,即:“//真实的url”。希望现在很清楚,我运行代码时接受了你的想法。但是(文件:///)仍然存在。没有删除。为什么?