How to post a message on Twitter using the android application?


I developed a twitter application . i need After enter a text into editbox, i click the button then its post to twitter.

can any one post the code.

I tried but i get error at setStatus() method.

here is my code please help.

public void onCreate(Bundle savedInstanceState) {
        System.setProperty("http.keepAlive", "false");

        //check for saved log in details..

        //set consumer and provider on teh Application service

        //Define login button and listener
        buttonLogin = (Button)findViewById(;
        buttonLogin.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {

        postText = (EditText)findViewById(;
        postbtn = (Button)findViewById(;

        postbtn.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub


    protected void postTwitter() {
        String message = postText.getText().toString();
        System.out.println("Post Twitter.."+message);

        Thread t = new Thread() {
            public void run() {

                 twitter = new Twitter();

                 //Status to post in Twitter
                 Toast.makeText(AuthActivity.this, "Article Posted to Twitter Successfully!!", Toast.LENGTH_SHORT).show();
                  catch(Exception e)
                 Toast.makeText(AuthActivity.this, "Network Host not responding",Toast.LENGTH_SHORT).show();


Posting from Android into Twitter is one of the earliest stages of an Android developer. To keep full control over the posting process, we will use prefer primarily a pure OAuth post instead of dealing with Intents, so we can keep full control. So as a user, we could just think and conclude: the most typical way to authenticate is to pop up a window where we can identify with our user and password to give the application access to our account (not the full account though, just to post from the application!) and forget about the rest of the process. This might be a bit tricky process for newbies in Android. And of course, Twitter will eventually change their API or registration method, so we will found sometimes that our old implementation is not working anymore

We first need to register a Twitter App. For that purpose, we will visit the developer website of Twitter. After login in, we will add a new application. There are no special settings to be remembered, but the part of the callback URL has changed very oftenly since Twitter released their API. At the moment, if we are developing one application we only need to provide any random URL.(More for this article)

Here one of the sample Android project to show how to connect to Twitter, save it’s token and username on shared preferences so it can be used later to post status to Twitter. How to Post Twitter Status from Android

Others exaples how to send message suing androd API . Here some of the link for your help;,

Build Android applications with Twitter

Don't forget to see this also;