I’m learning to incorporate the facebook sdk into an existing android application. I believe I have everything working well, however, my app shows a blank facebook page w/ progress loader whenever my application loads. Is this intentional? Can this page be hidden somehow?
public class MainActivity extends ListActivity{
Facebook facebook = new Facebook("***************");
String FILENAME = "AndroidSSO_data";
private SharedPreferences mPrefs;
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*
* Get existing access_token if any
*/
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}
/*
* Only call authorize if the access_token has expired.
*/
if(!facebook.isSessionValid()) {
facebook.authorize(this, new DialogListener() {
@Override
public void onComplete(Bundle values) {}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
}
...
//thread is created here to populate listview data
}
}
UPDATE: I now have the key hash working. I still see the default facebook page with progress loader before my listview is displayed. I’m also presented with the Permissions page everytime I launch the app now.
NEW UPDATE:
While logged into the official FB app (on the emulator), when I trace facebook.isSessionValid() from my application I receive “false”. Is this a bug? Any additional help is appreciated!
facebook.authorize will create a dialog if the device doesn’t support one-click-sign-in (in which case it’ll take you temporarily to the facebook app). The dialog uses a WebView to connect to a mobile friendly facebook login page and handles everything for you, reporting back through the DialogListener.
Since authorize is called in your onCreate method, it will display the dialog whenever the Activity is first started (and the sesson isn’t valid).