0
Я попытался выполнить щелчок программным способом, но приложение каждый раз сталкивается с сбоем.twitterLoginButton.performClick(); не работает в 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.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)
Да таким же образом, только я назвал. Пожалуйста, пройдите через опубликованный код один раз. –
Выведенный код вызывает performClick перед установкой обратного вызова. 'twitterLoginButton.setCallback' должен быть первым, что вы вызываете после установки twitterLoginButton –
Спасибо, его работа –