来自 Android 应用程序的简单推文

发布于 2025-01-05 16:42:28 字数 70 浏览 2 评论 0原文

如何从应用程序设置简单的推文。必须通过 Twitter 网站登录。 用户甚至必须填写任何文本。我只需要发推文。请提供并举例。

How do I setup simple a Tweet from an app. Login must be through the twitter website.
The user even have to fill in any text. I just need to tweet. Please provide and example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

第几種人 2025-01-12 16:42:28

以下代码应该对您有帮助:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(
  android.content.Intent.EXTRA_TEXT,
  "I'm a string that you want to tweet);
startActivity(
  Intent.createChooser(shareIntent, getString(R.string.share_via)));

这实际上是通用共享代码。它将获取所有可以处理发送操作的应用程序(如 facebook、twitter、电子邮件等),并让用户选择要使用的应用程序。这是您在 Android 应用程序的“共享”按钮中常见的功能类型。

The following code should help you:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(
  android.content.Intent.EXTRA_TEXT,
  "I'm a string that you want to tweet);
startActivity(
  Intent.createChooser(shareIntent, getString(R.string.share_via)));

This is actually generic sharing code. It will get all the application that can handle a Send Action (like facebook, twitter, e-mail, etc.) and let the user choose what application to use. This is the type of functionality you commonly see in a "share" button on an android app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文