bohr
bohr

Reputation: 651

TwitterFactory().getInstance() get no method suitable

i am trying to build a simple application that related to twitter. i have read so many tutorial about it, but i got an error in a very early step of code.

Twitter twitter = new TwitterFactory().getInstance(txtUsername.getText(),arrayToString(txtPassword.getPassword()));

where the txtUsername is an edit text and txtPassword is a passwordField. arrayToString method is this

 private String arrayToString(char[] arr)
{
    StringBuffer result = new StringBuffer();
    for(int i=0;i<arr.length;i++)
    {
        result.append(arr[i]);
    }
    return result.toString();
}

and here is the error

no suitable method found for getInstance(java.lang.String,java.lang.String)
method twitter4j.TwitterFactory.getInstance(twitter4j.auth.Authorization) is not applicable
  (actual and formal argument lists differ in length)
method twitter4j.TwitterFactory.getInstance(twitter4j.auth.AccessToken) is not applicable
  (actual and formal argument lists differ in length)
method twitter4j.TwitterFactory.getInstance() is not applicable

(actual and formal argument lists differ in length)

Thank you so much, any help will be very great..

Upvotes: 0

Views: 1253

Answers (1)

benjamin.d
benjamin.d

Reputation: 2871

The getInstance method you are trying to use doesn't exist in Twitter4J. If you look at the javadoc you will see that three getInstance methods are available:

Twitter getInstance()
Twitter getInstance(AccessToken accessToken)
Twitter getInstance(Authorization auth) 

That's why your compiler is complaining about the use of:

getInstance(String, String) 

Upvotes: 1

Related Questions