Encounter Authentication error 401 while trying to update status - Android


#1

I have been trying to create a update status function on the Android platform under the doInBackground in AsyncTask. Below are the code for the updating i am refering from http://stackoverflow.com/questions/17425692/integrate-twitter4j-v3-0-3-to-android-application-get-timeline-and-post-tweet. But everytime i try tweeting, i will always get a 401:Authentication credentials. Is there anything that i’m missing out?

ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);

            // Access Token
            String access_token = mSharedPreferences.getString(
                    PREF_KEY_OAUTH_TOKEN, "");
            // Access Token Secret
            String access_token_secret = mSharedPreferences.getString(
                    PREF_KEY_OAUTH_SECRET, "");

            AccessToken accessToken = new AccessToken(access_token,
                    access_token_secret);
            Twitter twitter = new TwitterFactory(builder.build())
                    .getInstance(accessToken);

            // Update status
            twitter4j.Status response = twitter.updateStatus(status);