我正在创建一个Android应用程序,其中我想添加Twitter分享按钮,点击Twitter按钮将在Twitter上分享一些东西(标题+网址).我快到了,但我的链接有问题.当我用"&"给出两个参数时,它将不起作用.如果有人有合适的答案,请告诉我.答案将非常感谢.
//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));
Run Code Online (Sandbox Code Playgroud)
输出:=>"http://www.mywebsite.com/index.php?option=com_content&catid=40"
但缺少=>"&id = 12546&view = article".