Android Twitter login not working with Fabric SDK - Callback must not be null

谁说我不能喝 提交于 2019-12-03 12:55:40

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!