Android posting to Twitter
I have seen that there are a few good libraries out there. These seem to come with all the bells and whistles.
My application only needs to post a status update to a twi开发者_JAVA技巧tter account. Each time the user would have to enter their details. This is not the major part of my app, so I was wondering if there are any condensed libraries or simpler ways to achieve this without including all of the features that come with larger libraries.
Any advice greatly appreciated.
You can use the ACTION_SEND intent. Any application capable of sharing, including a twitter and facebook apps if installed, listens for that intent. The system will then show a dialog to let the user choose how they want to share the message. Use something like the following code:
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, getString(R.string.share)));
精彩评论