title: Android: Login with Twitter using Twitter4J
body: <p><strong>What I Have Tried:</strong></p>
  
  <p>I already have registered an app in twitter and got Consumer Key and Secret.Even I got various codes to login with twitter.These are what I have tried from:</p>
  
  <p><a href="http://thetechnib.blogspot.com/2011/01/android-sign-in-with-twitter.html" rel="noreferrer">http://thetechnib.blogspot.com/2011/01/android-sign-in-with-twitter.html</a></p>
  
  <p>[This link is dead, you may view an archive <a href="http://web.archive.org/web/20130121120221/http://android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application" rel="noreferrer">here</a>]<br>
  <s><a href="http://www.android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application" rel="noreferrer">http://www.android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application</a></s></p>
  
  <p><strong>Problem I have:</strong></p>
  
  <p>Till now,above code takes me to twitter login and let me sign in and have a PIN to complete the login process.But I have no idea how to use it to get my app working.I checked the whole code but found nothing related to pin.</p>
  
  <p>Secondly,when I registered my app on twitter,it asked for Callback URL but as it was written that its really not needed,i skipped specifying.(Even I don't know what it should be!)</p>
  
  <p>And hence,I am giving null as CallbackURL in my app.</p>
  
  <p>Can anyone suggest me,how can I use this PIN to complete login process and get user back to my app's main activity? Is it the callback url which is causing problem or something else I am doing wrong at?</p>
  
  <p>Please reply.Any help appriciated! Thanks.</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>As suggested by Frankenstein,I tried code at github.com/ddewaele/AndroidTwitterSample/downloads</p>
  
  <p>I added my consumer key and consumer secret along with callback url:</p>
  
  <pre><code>public static final String OAUTH_CALLBACK_SCHEME= "x-oauthflow-twitter";
  public static final String OAUTH_CALLBACK_HOST= "callback";
  public static final String OAUTH_CALLBACK_URL= OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
  </code></pre>
  
  <p>but it gives me this error: </p>
  
  <p>Logcat:</p>
  
  <pre><code>11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): Error during OAUth retrieve request token
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:239)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:189)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at com.ecs.android.sample.twitter.OAuthRequestTokenTask.doInBackground(OAuthRequestTokenTask.java:55)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at com.ecs.android.sample.twitter.OAuthRequestTokenTask.doInBackground(OAuthRequestTokenTask.java:1)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at android.os.AsyncTask$2.call(AsyncTask.java:185)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081):   at java.lang.Thread.run(Thread.java:1096)
  </code></pre>
  
  <p>Also shows me black screen when i click on TWEET button,instead of taking me to sign in screen of twitter.</p>
  
  <p>Omg,I am going to be crazy...have been trying since two days! :( please help.</p>