i want to know about twitter api for android application.... please send me link or source for twitter api which api just only for send the tweet....
Asked
Active
Viewed 3.8k times
3 Answers
25
String tweetUrl = "https://twitter.com/intent/tweet?text=PUT TEXT HERE &url="
+ "https://www.google.com";
Uri uri = Uri.parse(tweetUrl);
startActivity(new Intent(Intent.ACTION_VIEW, uri));
For more info, check my answer on this other post
-
@giancarlo its working fine. but how can i come back to the same activity after its posted on twitter? – Seshu Vinay Jun 04 '12 at 09:47
-
2Simple and useful. No twitter4j is needed for simple tweets. – Yar Sep 11 '12 at 06:57
-
@gian1200 Can you share the intent extras that i need to send .. i am passing intent.putExtra("text", ArticleListAdapter.shareContent); intent.putExtra("url", ArticleListAdapter.link); these values but the page not shows this message ?????? – Sampath Kumar Jan 30 '14 at 06:39
-
You dont need extras. Just a long url with parameters – gian1200 Jan 30 '14 at 06:48
3
To share some text using standard android intents, only three lines of code are necessary. The user will be prompted to pick a method (and they can then choose Twitter.)
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_TEXT, "Here's some text for Twitter.");
startActivity(Intent.createChooser(share, "Share this via"));
If you want to do more advanced stuff with Twitter:
I found that a lot of the solutions posted on the Internet were needlessly complicated. For me, it was only a couple additional lines of code beyond what Twitter4J tells you to do.
For my dollar, Stephan's answer here is the best.
I have some example code on github using his technique, here.
0
Code :
protected String doInBackground(String... args) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(CONSUMER_KEY);
builder.setOAuthConsumerSecret(CONSUMER_SECRET);
AccessToken accessToken = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
Twitter twitter = new TwitterFactory(builder.build()).getInstance(accessToken);
try {
twitter4j.Status response = twitter.updateStatus(tweetText);
return response.toString();
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}

Dmarp
- 208
- 1
- 3
- 13