twitterLoginButton.performClick();不在 android 工作

twitterLoginButton.performClick(); not working in android

我尝试以编程方式执行点击,但应用程序每次都崩溃。

twitterLoginButton = (TwitterLoginButton) findViewById(R.id.twitterLogin);
    twitterLoginButton.performClick();
    twitterLoginButton.setPressed(true);
    twitterLoginButton.invalidate();
    //Adding callback to the button
    twitterLoginButton.setCallback(new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {
            //If login succeeds passing the Calling the login method and passing Result object
            twitterLogin(result);
        }
        @Override
        public void failure(TwitterException exception) {
            //If failure occurs while login handle it here
            Log.d("TwitterKit", "Login with Twitter failure", exception);
        }
    });
    twitterLoginButton.setPressed(false);
    twitterLoginButton.invalidate();

出现以下错误。手动按钮点击正常,不能figure_out问题...

 FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.tettares.whatdoieat/com.tettares.whatdoieat.login.FBOrTwitterLoginActivity}: java.lang.IllegalArgumentException: Callback must not be null 
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
 at android.app.ActivityThread.access0(ActivityThread.java:155) 
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) 
 at android.os.Handler.dispatchMessage(Handler.java:102)at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
 Caused by: java.lang.IllegalArgumentException: Callback must not be null. at 
  com.twitter.sdk.android.core.identity.TwitterAuthClient.authorize(TwitterAuthClient.java:95)at 
  com.twitter.sdk.android.core.identity.TwitterLoginButton$LoginClickListener.onClick(TwitterLoginButton.java:161) 
  at android.view.View.performClick(View.java:4785)

设置回调后调用twitterLoginButton.performClick();