title: How to implement a Login screen with Twitter Kit for Android?
body: <p>I am trying to implement a Twitter functionality inside my custom Android app by using their new Twitter Kit 3 API, but I cannot make it work.</p>
  
  <p>I just followed this example: <a href="https://dev.twitter.com/twitterkit/android/log-in-with-twitter" rel="nofollow noreferrer">https://dev.twitter.com/twitterkit/android/log-in-with-twitter</a></p>
  
  <p>My MainActivity class is the following:</p>
  
  <pre><code>package gib.twitterpruebacliente;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.Toast;
  
  import com.twitter.sdk.android.core.Callback;
  import com.twitter.sdk.android.core.Result;
  import com.twitter.sdk.android.core.Twitter;
  import com.twitter.sdk.android.core.TwitterException;
  import com.twitter.sdk.android.core.TwitterSession;
  import com.twitter.sdk.android.core.identity.TwitterLoginButton;
  
  public class MainActivity extends AppCompatActivity {
  
  private TwitterLoginButton loginButton;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      Twitter.initialize(this);
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      loginButton = (TwitterLoginButton) findViewById(R.id.login_button);
      loginButton.setCallback(new Callback&lt;TwitterSession&gt;() {
          @Override
          public void success(Result&lt;TwitterSession&gt; result) {
              // Do something with result, which provides a TwitterSession for making API calls
              Toast.makeText(MainActivity.this, "IT WORKS!", Toast.LENGTH_SHORT).show();
          }
  
          @Override
          public void failure(TwitterException exception) {
              // Do something on failure
              Toast.makeText(MainActivity.this, "FAIL!", Toast.LENGTH_SHORT).show();
          }
      });
      }
  
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      // Pass the activity result to the login button.
      loginButton.onActivityResult(requestCode, resultCode, data);
  }
  }
  </code></pre>
  
  <p>My XML activity main just have a TwitterLoginButton:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="gib.twitterpruebacliente.MainActivity"&gt;
  
  
      &lt;com.twitter.sdk.android.core.identity.TwitterLoginButton
          android:id="@+id/login_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>I have already added the permission on the Manifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>
  
  <p>And I added the KEYS for my app in the strings folder:</p>
  
  <pre><code>   &lt;string name="com.twitter.sdk.android.CONSUMER_KEY"&gt;suP4TlwNI7xpwh3sK4x5fKldL&lt;/string&gt;
  &lt;string name="com.twitter.sdk.android.CONSUMER_SECRET"&gt;oaAzoqtMlu5ZtY40LPdzfZTk5wNSTg6Lrnkgx5MPc4TTLbfzMZ&lt;/string&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/MemfW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MemfW.png" alt="key"></a></p>
  
  <p>But the app always enters on the failure section. How can I do?</p>
  
  <p><a href="https://i.stack.imgur.com/hN3bb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hN3bb.png" alt="failure"></a></p>