title: Facebook SSO not working in android
body: <p>I used the following code to Login through Facebook in my app. I need to do this with Facebook SSO. I have the correct app_id. </p>
  
  <pre><code>package com.fb.sso;
  
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.net.MalformedURLException;
  
  import com.facebook.android.AsyncFacebookRunner;
  import com.facebook.android.AsyncFacebookRunner.RequestListener;
  import com.facebook.android.DialogError;
  import com.facebook.android.Facebook;
  import com.facebook.android.Facebook.DialogListener;
  import com.facebook.android.FacebookError;
  import com.facebook.android.Util;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.os.Handler;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  public class FBSSOActivity extends Activity {
      /** Called when the activity is first created. */
  
  
      public static final String APP_ID = "my_app_id";
  
      private static final String[] PERMISSIONS = new String[] {
              "publish_stream", "read_stream", "offline_access" };
      private TextView mText;
      private Handler mHandler = new Handler();
  
      private Facebook mFacebook;
      private AsyncFacebookRunner mAsyncRunner;
      byte[] raw;
      private SharedPreferences mPrefs;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
          if (APP_ID == null) {
              Util.showAlert(this, "Warning",
                      "Facebook Applicaton ID must be set...");
          }
  
          // Initialize the content view
          setContentView(R.layout.main);
  
          // Initialize the Facebook session
          mFacebook = new Facebook(APP_ID);
          mAsyncRunner = new AsyncFacebookRunner(mFacebook);
  
          mPrefs = getPreferences(MODE_PRIVATE);
          String access_token = mPrefs.getString("access_token", null);
          long expires = mPrefs.getLong("access_expires", 0);
          if (access_token != null) {
              mFacebook.setAccessToken(access_token);
          }
          if (expires != 0) {
              mFacebook.setAccessExpires(expires);
          }
  
      }
  
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          Log.d("FB Sample App", "onActivityResult(): " + requestCode);
          mFacebook.authorizeCallback(requestCode, resultCode, data);
      }
  
  
  
      private class LogoutRequestListener implements RequestListener {
  
          @Override
          public void onComplete(String response, Object state) {
              // TODO Auto-generated method stub
  
  Log.v("comes here&gt;&gt;.","sucess");
              // Only the original owner thread can touch its views
              FBSSOActivity.this.runOnUiThread(new Runnable() {
                  public void run() {
                      mText.setText("Thanks for using FB Sample App. Bye bye...");
  
                  }
              });
  
              // Dispatch on its own thread
              mHandler.post(new Runnable() {
                  public void run() {
                  }
              });
  
          }
  
          @Override
          public void onIOException(IOException e, Object state) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onFileNotFoundException(FileNotFoundException e,
                  Object state) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onMalformedURLException(MalformedURLException e,
                  Object state) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onFacebookError(FacebookError e, Object state) {
              // TODO Auto-generated method stub
              Log.v("facebook error","fb error");
          }
              }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.main_menu, menu);
          return true;
      }
  
  
      @Override
      public boolean onPrepareOptionsMenu(Menu menu) {
  
          MenuItem loginItem = menu.findItem(R.id.login);
  
          if (mFacebook.isSessionValid()) {
              loginItem.setTitle("Logout");
  
  
          } else {
              loginItem.setTitle("Login");
  
  
          }
          loginItem.setEnabled(true);
          return super.onPrepareOptionsMenu(menu);
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
  
          // Login/logout toggle
          case R.id.login:
  
              if (!mFacebook.isSessionValid()) {
  
                  mFacebook.authorize(this, new DialogListener() {
  
                      @Override
                      public void onComplete(Bundle values) {
                          // TODO Auto-generated method stub
  
                          Log.v("Entered ", "No ERRRRRRRRRRRR");
                          SharedPreferences.Editor editor = mPrefs.edit();
                          editor.putString("access_token",
                                  mFacebook.getAccessToken());
                          editor.putLong("access_expires",
                                  mFacebook.getAccessExpires());
                          editor.commit();
                          Intent i=new Intent(FBSSOActivity.this,second.class);
                          startActivity(i);
  
                      }
  
                      @Override
                      public void onFacebookError(FacebookError e) {
                          // TODO Auto-generated method stub
  
                      }
  
                      @Override
                      public void onError(DialogError e) {
                          // TODO Auto-generated method stub
  
                      }
  
                      @Override
                      public void onCancel() {
                          // TODO Auto-generated method stub
  
                      }
  
                  });
              }else{
  
                  mFacebook.setAccessToken(null);
                  mFacebook.setAccessExpires(0);
  
                  AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(mFacebook);
                   asyncRunner.logout(this.getBaseContext(), new  LogoutRequestListener());
              }
  
              break;
  
  
          default:
              return false;
  
          }
          return true;
      }
  
      }
  </code></pre>
  
  <p>I logged in to preinstalled Facebook app in my device. And I got this screen only.
  <img src="https://i.stack.imgur.com/8kY6z.png" alt="enter image description here"></p>
  
  <p>And in my Logcat this line appears.</p>
  
  <pre><code>09-28 15:18:24.652: E/ActivityThread(1201): Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
  </code></pre>
  
  <p>If I logged out from my preinstalled Facebook app, my application prompts me to login, asking the credentials. That time also, the empty screen appears.But in the preinstalled Facebook app, I can see my updates.( I get Logged in).</p>
  
  <p>Update:</p>
  
  <p>Right now I'm checking the app only. I have not published it to market. I got the key by referring this site <a href="http://sean.lyn.ch/2011/07/android-the-facebook-sdk-sso-and-you/" rel="nofollow noreferrer">http://sean.lyn.ch/2011/07/android-the-facebook-sdk-sso-and-you/</a>. And I added it to the app, like this.
  <img src="https://i.stack.imgur.com/l4ip9.png" alt="enter image description here"></p>
  
  <p>Update 2:
   Now I got these lines in logcat:</p>
  
  <pre><code>09-29 12:00:12.552: I/ActivityManager(73): Starting activity: Intent { cmp=com.facebook.katana/.ProxyAuth (has extras) }
  09-29 12:00:13.022: I/ActivityManager(73): Displayed activity com.facebook.katana/.ProxyAuth: 436 ms (total 436 ms)
  09-29 12:00:15.032: W/InputManagerService(73): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@434b2e88 (uid=10031 pid=2233)
  09-29 12:00:15.032: W/IInputConnectionWrapper(2233): showStatusIcon on inactive InputConnection
  </code></pre>