如何使用Twitter的整合Android应用程序发布在Twitter上墙留言 [英] How to post message on twitter wall using twitter integrate android app

查看:178
本文介绍了如何使用Twitter的整合Android应用程序发布在Twitter上墙留言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想微博融入我的Andr​​oid应用程序,这样我可以发布消息到Twitter。

I would like to integrate Twitter into my Android application so that I can post messages to Twitter.

推荐答案

这真的取决于你如何想的交互工作。您可以:

It really depends on how you want the interaction to work. You can:

  1. 使用它们 API (由库如twitter4j帮助建议的那样,海科鲁普),或
  2. 找到一种方法来与Twitter的应用程序整合,虽然目前还没有公布的协议,这是据我所知。这也不是一个好主意,因为很多人使用其他应用程序,如Twidroyd,TweetDeck的等等,但它一定会很酷,或者
  3. 如果您不希望用户能够做到这一点,很多时候,你只需打开 http://twitter.com/?status=<what-to-tweet> 用一个简单的意向。
  1. Use their API (helped by a library such as twitter4j, as suggested by Heiko Rupp), or
  2. Find a way to integrate with the Twitter app, although there is no published protocol for this as far as I know. This is also not a good idea because many people use other apps such as Twidroyd, TweetDeck and so on, but it would definitely be cool, or
  3. If you don't expect the user to do this very often, you can just open up http://twitter.com/?status=<what-to-tweet> using a simple intent.

3的方法可以在这里轻松地描述:

Method 3 can be easily described here:

Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("http://twitter.com/?status=" + Uri.encode(message)));
startActivity(i);

您还可以结合2和3。你可以尝试一些已知的应用程序(官方微博,TweetDeck的,...),如果所有的人都失败(因为他们不是present或者是因为他们已被更新并打破了该协议),你采取开放的浏览器。

You can also combine 2 and 3. You can try a few known apps (official Twitter, TweetDeck, ...) and if all of them fail (because they're not present or because they have been updated and broke the protocol) you resort to opening up the browser.

还要注意,有可能对方法3来实际启动而不是浏览器的应用程序(或至少给用户两者之间的选择),如果该应用处理的正确的意图。

Also note that it might be possible for method 3 to actually launch an app instead of the browser (or at least give the user a choice between the two), if the app handles the correct intents.

另外一点值得一提的是,这是很可能的,你将无法与任何Twitter的应用程序集成。我在这里说纯属假设,我不知道这些应用程序是否支持这样的集成。您应该咨询每个应用程序,看看他们是否暴露了一些意向,你可以使用。如果他们不这样做,你仍然可以破解绕一点,你会发现它们,但这样做是不可靠的,因为他们会经过几个更新最有可能打破。

Another thing worth mentioning is that it's very possible that you will not be able to integrate with any Twitter apps. What I've said here is purely hypothetical, I have no idea whether these apps support such integrations. You should consult each app and see if they expose some intents that you could use. If they don't, you can still hack around a little and you might find them, but that will be unreliable because they will most probably break after a couple of updates.

这篇关于如何使用Twitter的整合Android应用程序发布在Twitter上墙留言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆