【问题标题】:Tweet in android app instead authenticating the user在 android 应用程序中发推文而不是对用户进行身份验证
【发布时间】:2012-05-20 20:38:15
【问题描述】:

我正在开发一个 android 应用程序,我想在推文中分享一张图片。我搜索教程,所有教程都必须先对用户进行身份验证,然后才能发布推文。有什么方法可以使用手机上存储的帐户而不是再次验证用户身份?

我不想有分享按钮,我希望像在 iPhone 中一样可以发布推文。

如果有人知道其他可行的教程,最好告诉我,我不想要分享按钮,只想发推文。

谢谢

【问题讨论】:

  • “我不想有分享按钮”——编写良好的应用程序允许他们的用户决定每个用户想要如何分享用户的内容,可能涉及也可能不涉及 Twitter。
  • 是的,但我正在开发的应用不像是想要分享结果的游戏,更像是一个推特客户端。
  • 如果它是 Twitter 客户端,那么用户将需要向您(或直接通过 OAuth 的 Twitter)提供帐户凭据,因为可能他们没有使用任何其他 Twitter 客户端。
  • 我最终以一个选定的分享意图拯救了我。 stackoverflow.com/questions/8308666/… 谢谢大家

标签: android twitter


【解决方案1】:

使用shareIntent,如here所述:

public void shareTwitter() {
        String message = "Your message to post";
        try {
            Intent sharingIntent = new Intent(Intent.ACTION_SEND);
            sharingIntent.setClassName("com.twitter.android","com.twitter.android.PostActivity");
            sharingIntent.putExtra(Intent.EXTRA_TEXT, message);
            startActivity(sharingIntent);
        } catch (Exception e) {
            Log.e("In Exception", "Comes here");
            Intent i = new Intent();
            i.putExtra(Intent.EXTRA_TEXT, theObject.getName());
            i.setAction(Intent.ACTION_VIEW);
            i.setData(Uri.parse("https://mobile.twitter.com/"));
            startActivity(i);
        }
    }

【讨论】:

  • 哦,谢谢你,但是我前几天找到了这个解决方案,抱歉没有删除帖子...
  • 我可以为推文附上图片吗?
猜你喜欢
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-19
  • 1970-01-01
  • 2018-08-20
  • 1970-01-01
相关资源
最近更新 更多