How can I post on Twitter with Intent Action_send?

后端 未结 5 1736
野趣味
野趣味 2020-12-05 15:37

I have been struggling to send text from my app to Twitter.

The code below works to bring up a list of apps such as Bluetooth, Gmail, Facebook and Twitter, but when

5条回答
  •  生来不讨喜
    2020-12-05 16:15

    you can simply open the URL with the text and Twitter App will do it. ;)

    String url = "http://www.twitter.com/intent/tweet?url=YOURURL&text=YOURTEXT";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);
    

    and it will also open the browser to login at the tweet if twitter app is not found.

提交回复
热议问题