これは私が自分のアプリケーションを実行すると、Twitterのボタンをクリックすることができないと動作していない表示されます。AndroidのTwitterのログインボタン[firebase払い]エラー:Twitterのに:(シングルトンを使用する前に、ファブリックを初期化する必要があります)
これは、Twitterのログインボタンのコードです:
mLoginButton = (TwitterLoginButton) findViewById(R.id.button_twitter_login);
mLoginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
Log.d(TAG, "twitterLogin:success" + result);
handleTwitterSession(result.data);
}
@Override
public void failure(TwitterException exception) {
Log.w(TAG, "twitterLogin:failure", exception);
updateUI(null);
}
});
私は方法OnCreate
にこのコードを配置:
TwitterAuthConfig authConfig = new TwitterAuthConfig(
getString(R.string.twitter_consumer_key),
getString(R.string.twitter_consumer_secret));
Fabric.with(this, new Twitter(authConfig));
私はこのようなOnActivityResultに設定
:その後、私はこのようなエラーが出る
private void handleTwitterSession(TwitterSession session) {
Log.d(TAG, "handleTwitterSession:" + session);
// [START_EXCLUDE silent]
showProgressDialog();
// [END_EXCLUDE]
AuthCredential credential = TwitterAuthProvider.getCredential(
session.getAuthToken().token,
session.getAuthToken().secret);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Log.w(TAG, "signInWithCredential", task.getException());
Toast.makeText(LoginActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// [START_EXCLUDE]
hideProgressDialog();
// [END_EXCLUDE]
}
});
}
アリ::これは私がonClick
さえずりボタンで呼び出す方法twitterSession
ためのコードである
mLoginButton.onActivityResult(requestCode, resultCode, data);
E/Twitter: Must Initialize Fabric before using singleton()
は助け@Cristikいただきありがとうございます。私はこのコードを試してみますが、 "Twitter:シングルトン()を使用する前にファブリックを初期化する必要があります"のようなエラーです。多分誰でも私を助けることができる –