Android,Twitter的“授权”AppName“使用您的帐户?”屏幕每次都会出现

时间:2016-03-14 11:29:38

标签: android twitter twitter-oauth

我已经在我的应用程序中集成了Twitter登录,使用了Fabric(从Fabric插件中复制了代码)。它工作正常,但每次出现此屏幕时:

enter image description here

我怎么能摆脱这个? 这是我使用的代码:

登录片段:

private void onTwitterLogin() {
        twitterlogin.setCallback(new Callback<TwitterSession>() {
            @Override
            public void success(Result<TwitterSession> result) {
                session = result.data;

                auth_token = session.getAuthToken();

                Twitter.getApiClient(session).getAccountService()
                        .verifyCredentials(true, false, new Callback<com.twitter.sdk.android.core.models.User>() {

                            @Override
                            public void failure(TwitterException e) {

                            }

                            @Override
                            public void success(Result<com.twitter.sdk.android.core.models.User> userResult) {

                                com.twitter.sdk.android.core.models.User tUser = userResult.data;
                                String twitterImage = tUser.profileImageUrl;

                                username = tUser.screenName;
                                name = tUser.name;

                                new TwitterLoginTask().execute(username, name, social_type);
                            }

                        });
            }

            @Override
            public void failure(TwitterException exception) {
                Toast.makeText(getActivity(), "You don't have Twitter application \ninstalled in your device", Toast.LENGTH_LONG).show();
            }
        });
    }

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
    twitterlogin.onActivityResult(requestCode, resultCode, data);
    }

MainActivity:

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    FragmentManager fragment = getSupportFragmentManager();

    if (fragment != null) {fragment.findFragmentByTag("LoginFragment").onActivityResult(requestCode, resultCode, data);
    }
}

0 个答案:

没有答案