title: How to do yahoo integration in Android?
body: <p>I'm developing a yahoo login integration in Android App and return into main Activity. I have completed all the steps of yahoo integration.I have spent several days for searching yahoo integration in android but i cant find proper way.When i run this code and proper sign in yahoo email and when i click agree button it comes always call_Back URL. Please can anyone help mi.Here is my code</p>
  
  <pre><code>public class RequestTokaenActivity2 extends Activity
  {
      private OAuthConsumer consumer;
      private OAuthProvider provider;
      private SharedPreferences yahooPrefs;
      private CommonsHttpOAuthConsumer myConsumer;
      private CommonsHttpOAuthProvider myProvider;
      private String requestToken;
      private String accessToken;
  
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
  
          try
          {
              consumer=new CommonsHttpOAuthConsumer(c1.CONSUMER_KEY,c1.CONSUMER_SECRET);
  
              consumer.setMessageSigner(new HmacSha1MessageSigner());
              HttpClient httpCliet=new DefaultHttpClient();
  
  
              provider=new CommonsHttpOAuthProvider(c1.REQUEST_URL,c1.ACCESS_URL,c1.AUTHORIZE_URL,httpCliet);
              provider.setOAuth10a(true);
              String strUrl=provider.retrieveRequestToken(consumer,c1.OAUTH_CALLBACK_URL);
              requestToken=consumer.getToken();
              startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(strUrl)));
  
          }
  
          catch(Exception ex)
          {
              Toast.makeText(getApplicationContext(),ex.getMessage(),Toast.LENGTH_LONG).show();
              Log.e(ex.getMessage(), ex.toString());
  
          }
  
  
  
      }
  
      @Override
  
      public void onNewIntent(Intent intent)
      {
          super.onNewIntent(intent);
          yahooPrefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
          final Uri uri=intent.getData();
  
          if(uri!=null &amp;&amp; uri.getScheme().equals(c1.OAUTH_CALLBACK_SCHEME))
          {
              Log.i(c1.TAG, "Callback received : " + uri);
              Log.i(c1.TAG, "Retrieving Access Token");
              getAccessToken(uri);
          }
  
      }
  
  
      private void getRequestToken()
      {
          try
          {
              String url=provider.retrieveRequestToken(consumer, c1.OAUTH_CALLBACK_URL);
              Intent i=new Intent(Intent.ACTION_VIEW , Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_FROM_BACKGROUND );
              this.startActivity(i);
  
  
          }
          catch(Exception e1)
          {
              e1.printStackTrace();
              Log.e(c1.TAG, "Error retrieving request token", e1);
          }
      }
  
      private void getAccessToken(Uri uri)
      {
  
          final String oauthVerifier=uri.getQueryParameter(OAuth.OAUTH_VERIFIER);
          final Editor edit=yahooPrefs.edit();
          edit.putString(OAuth.OAUTH_TOKEN,consumer.getToken());
          edit.putString(OAuth.OAUTH_TOKEN_SECRET,consumer.getTokenSecret());
          edit.commit();
  
          String token=yahooPrefs.getString(OAuth.OAUTH_TOKEN, "");
          String secret=yahooPrefs.getString(OAuth.OAUTH_TOKEN_SECRET,"");
  
          consumer.setTokenWithSecret(token, secret);
          this.startActivity(new Intent(this,OAuthMain.class));
          Log.i(c1.TAG, "Access Token Retrieved");
  
      }
  
  }
  
  
  
  
  
  
    public class c1 
      {
          public static final String CONSUMER_KEY     = "xxxxxxxxxx";
          public static final String CONSUMER_SECRET  = "xxxxxxxxxx";
  
  
          public static final String SCOPE            = "http://social.yahooapis.com/v1/user/";
  
          public static final String REQUEST_URL      = "https://api.login.yahoo.com/oauth/v2/get_request_token";
  
          //https://api.login.yahoo.com/oauth/v2/
  
          public static final String ACCESS_URL       = "https://api.login.yahoo.com/oauth/v2/get_access_token"; 
          //https://api.login.yahoo.com/oauth/v2/get_token"
  
          public static final String AUTHORIZE_URL    = "https://api.login.yahoo.com/oauth/v2/request_auth";
          //https://api.login.yahoo.com/oauth/v2/request_auth"
          //public static final String UNAUTHORIZE_URL  = "https://accounts.google.com/o/oauth2/revoke";
  
          public static final String GET_CONTACTS_FROM_YAHOO_REQUEST="http://social.yahooapis.com/v1/user/{guid}/contacts";
  
          public static final String ENCODING = "UTF-8";
  
          public static final String  OAUTH_CALLBACK_SCHEME   = "http";
          public static final String  OAUTH_CALLBACK_HOST     = "www.bcod.co.in";
          public static final String  OAUTH_CALLBACK_URL      = OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
          public static final String  APP_NAME                = "Demo_Oauth1";
          public static final String  TAG = null;
  
      }
  </code></pre>