1
votes

I'm using the Twitter kit for having a Login Facility on an Android App.

I'm using these depenencies -

compile 'com.twitter.sdk.android:twitter-core:3.1.1'
compile 'com.twitter.sdk.android:tweet-ui:3.1.1'

I'm initializing it like this in the Application Context class -

TwitterConfig config = new TwitterConfig.Builder(getApplicationContext())
                .logger(new DefaultLogger(Log.DEBUG))
                .twitterAuthConfig(new TwitterAuthConfig(getString(R.string.Twitter_CONSUMER_KEY), getString(R.string.Twitter_CONSUMER_SECRET)))
                .debug(false)
                .build();
Twitter.initialize(config);

In my Activity I have this code for Click listener on a button that calls Twitter API for Login. twitter_login is a TextView. -

twitter_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mTwitterAuthClient = new TwitterAuthClient();

                mTwitterAuthClient.authorize(getActivity(), new Callback<TwitterSession>() {

                    @Override
                    public void success(Result<TwitterSession> twitterSessionResult) {
                        session = TwitterCore.getInstance().getSessionManager().getActiveSession();
                        TwitterAuthToken authToken = session.getAuthToken();

                        twitter_token = authToken.token;
                        twitter_secret = authToken.secret;

                        if (mTwitterAuthClient != null) {
                            (mTwitterAuthClient.requestEmail(session, new com.twitter.sdk.android.core.Callback<String>() {
                                @Override
                                public void success(Result<String> emailResult) {
                                    emailFromTwitter = emailResult.data;

                                }

                                @Override
                                public void failure(TwitterException e) {

                                    String error_message = e.getMessage();
                                }
                            });
                        }

                    }

                    @Override
                    public void failure(TwitterException e) {

                    }
                });

I have this inside onActivityResult -

mTwitterAuthClient.onActivityResult(requestCode, resultCode, data);

The case is that

  1. When I click on twitter_login, if I have the Twitter App installed on my Android phone, it shows the Authorization screen and login works fine.

  2. But I don't even get a Login Screen if Twitter App is not installed on my Android phone when I click on twitter_login. In this case how to prompt the user to enter his/her twitter credentials for login ?

Why is it so ? How to fix it ? Am I doing anything wrong ?

1
My question is if the Twitter App is not installed, how do I get the user logged in using twitter credentials ? There should be a way to prompt a dialog or a screen for this, I guess. But I'm not getting how to.Gissipi_453

1 Answers

0
votes

You have to add the call back URL Open your application in https://apps.twitter.com and select your app, in settings tab add callback URL as below twittersdk://

Ref : link