I'm trying to implement logging in with twitter in my app. I just came across news that states that Fabric was sold to Google. I am not using Fabric in my application. Instead I am using the twitter core sdk com.twitter.sdk.android:twitter-core:3.1.1
. I try to initialise Twitter but the login button is still greyed out with this code:
TwitterConfig config = new TwitterConfig.Builder(this)
.logger(new DefaultLogger(Log.DEBUG))
.twitterAuthConfig(new TwitterAuthConfig(getString(R.string.twitter_key), getString(R.string.twitter_secret)))
.debug(true)
.build();
Twitter.initialize(config);
I see the following error output in my logcatE/Twitter: Must initialize Twitter before using getInstance()
How can I go about this error?
Those unable to reply to tweets will see the option greyed out in the same way those who protect their tweets from being retweeted. The default setting will continue to be 'everyone' unless the user states otherwise. The setting won't affect who can like, retweet, retweet with comment and share the tweet.
If you can't reply to a tweet, the reply icon will be greyed out so that it's clear for people they aren't able to reply - just as the retweet button is currently for a tweet from a locked account.
To solve the problem, I took my Twitter.initialize(TwitterConfig)
statement before Android's setContentView()
method and problem solved:
Sample Code
TwitterConfig config = new TwitterConfig.Builder(this)
.logger(new DefaultLogger(Log.DEBUG))
.twitterAuthConfig(new TwitterAuthConfig(getString(R.string.twitter_key), getString(R.string.twitter_secret)))
.debug(true)
.build();
Twitter.initialize(config);
setContentView(R.layout.activity_login);
mLoginButton = (TwitterLoginButton) findViewById(R.id.login_twitter);
mLoginButton.setCallback(new Callback<TwitterSession>() {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With