【发布时间】:2012-12-31 09:48:34
【问题描述】:
我正在创建一个 android 应用程序,其中我想添加 Twitter 分享按钮,点击 Twitter 按钮将在 Twitter 上分享一些东西(标题 + url)。我快到了,但链接有问题。当我用“&”给两个参数时,它不起作用。请让我知道是否有人有我可以实施的合适答案。非常感谢您的回答。
//Full URL: http://www.mywebsite.com/index.php?option=com_content&catid=40&id=12546&view=article**
String title = "Hello title";
String catid = "40";
String id = "12546";
Uri.Builder b = Uri.parse("http://www.mywebsite.com/").buildUpon();
b.path("index.php");
b.appendQueryParameter("option=com_content&catid", catid);
b.appendQueryParameter("&id", id);
b.appendQueryParameter("&view=article", null);
b.build();
String url = b.build().toString();
String tweetUrl = "https://twitter.com/intent/tweet?text=" + title + "&url=" + url;
Uri uri = Uri.parse(tweetUrl);
startActivity(new Intent(Intent.ACTION_VIEW, uri));
输出:=> “http://www.mywebsite.com/index.php?option=com_content&catid=40”
但 => “&id=12546&view=article” 不见了。
【问题讨论】:
标签: android twitter parameters