How to Tweet Both URLs and Hashtags

Following this example in another thread, I can scroll or url:

String tweetUrl = "https://twitter.com/intent/tweet?text=PUT TEXT HERE &url=" + "https://www.google.com"; Uri uri = Uri.parse(tweetUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); 

which is displayed as:

PUT TEXT HERE https://www.google.com

or hashtags:

 String tweetUrl = "https://twitter.com/intent/tweet?text=PUT TEXT HERE &url=" + "https://www.google.com &hashtags=android,twitter"; Uri uri = Uri.parse(tweetUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); 

which is displayed as:

PUT TEXT HERE #android #twitter

But for some reason, I can’t show both the URL and hash tags in the Twitter block.

What am I doing wrong?

+6
source share
1 answer

Answering my own question: there should not be a space before &hashtags . In other words, the above should be written:

 String tweetUrl = "https://twitter.com/intent/tweet?text=PUT TEXT HERE &url=" + "https://www.google.com&hashtags=android,twitter"; Uri uri = Uri.parse(tweetUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); 

Hope this helps someone.

+6
source

Source: https://habr.com/ru/post/914757/


All Articles