I tried to perform click programmatic way, But app getting crash everytime.
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();
Given below error. Manual button clicks working fine, cannot figure_out the problem...
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.access$800(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)
Call twitterLoginButton.performClick();
after you set your callback