Skip to content Skip to sidebar Skip to footer

Android Twitter Login Not Working With Fabric Sdk - Callback Must Not Be Null

I'm working on a feature that needs to access the public data of Twitter users through the Twitter REST API, and I'm using Twitter's Fabric SDK for logging into Twitter. Here is th

Solution 1:

Well, we make the stupidest mistakes. The Callback<TwitterSession> object needs to be set BEFORE the user clicks on the TwitterLoginButton. Add the following code to your onCreate() or onActivityCreated() or onResume() method:

buttonLogin.setCallback(new Callback<TwitterSession>() {
    @Override
    public void success(Result<TwitterSession> result) {
        // ... do something
    }

    @Override
    public void failure(TwitterException exception) {
        // ... do something
    }
});

The mistake was that I had put this code in the Twitter button click listener, which is wrong naturally. You need to set the callback before the button is clicked, not after.

Post a Comment for "Android Twitter Login Not Working With Fabric Sdk - Callback Must Not Be Null"