I have to add an option to my game for posting highscores to twitter. The idea is that the app has it\'s own twitter account and the user can upload the score to this specific a
I have found a solution for this problem. Thought I share it here in case anyone has the same problem.
Here's the code I used in my app:
You need to include the twitter4j-core-android-2.2.5.jar package for this. You can download it from here: http://twitter4j.org/archive/twitter4j-android-2.2.5.zip
tweet=(Button)findViewById(R.id.tweetbtn);
message=(EditText)findViewById(R.id.messagetxt);
tweet.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
String token ="";
String secret = "";
AccessToken a = new AccessToken(token,secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer("", "");
twitter.setOAuthAccessToken(a);
try {
twitter.updateStatus(message.getText().toString());
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});