【问题标题】:Android : how to post a tweet only by Tweet (not by Direct Message?)Android:如何仅通过推文(而不是直接消息?)发布推文
【发布时间】:2017-06-22 01:09:05
【问题描述】:

这是我用来分享推文的代码:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.setPackage("com.twitter.android");
intent.putExtra(Intent.EXTRA_TEXT, "My text");
startActivity(intent);

这会打开一个弹出窗口,当我只想通过推文共享它时,用户可以通过推文或直接消息共享它。我该怎么做?

非常感谢。

【问题讨论】:

  • 可能通过使用一些专用的 Twitter Android API。此外,你想要什么并不重要。 用户想要什么很重要。 Share where the user wants,而不是人为地限制它们。

标签: android android-intent twitter


【解决方案1】:

试试这个:

    Intent tweet = new Intent(Intent.ACTION_VIEW);
    tweet.setData(Uri.parse("http://twitter.com/?status=" +   Uri.encode(message)));// replace message by your string message
    startActivity(tweet);

【讨论】:

    猜你喜欢
    • 2021-10-24
    • 2012-08-27
    • 1970-01-01
    • 2013-07-06
    • 2013-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多