This is how I retrieve information stored in general preferences and then compare if a username and password exist. If the user is logged in, I can show another action.
Settings SharedPreferences = getSharedPreferences ("logindetails", 0);
String username = settings.getString("username", ""); String password = settings.getString("password", "");
But now I'm trying to get the username and gender of the user and display in my activity.
I am trying to solve this, but have not yet found a convincing result.
Can someone help me get out of my requirement?
Note. I also see documents on the Facebook developers page.
This is the code that I use to retrieve user data and display in another action. What problem is that the layout is loading before the answer from facebook is parsed. I suspect this is due to the use of mAsyncRunner, as it controls the control itself. What I'm trying to figure out is hwo to analyze it before loading the layout.
public class FaceBookRetrieval extends Activity{ this.facebookConnector = new FacebookConnect(APP_ID, this, getApplicationContext(), PERMS); } public class FacebookConnect { public FacebookConnect fb = null; private Facebook facebook = null; private Context context; private String[] permissions; public static final String TAG = "FACEBOOK"; private AsyncFacebookRunner mAsyncRunner; private SharedPreferences sharedPrefs; private ProgressBar pb; public String fbName, fbGender; private Activity activity; public String check = "false"; private SessionListener mSessionListener = new SessionListener();; public FacebookConnect(String appId, Activity activity, Context context, String[] permissions) { this.facebook = new Facebook(appId); mAsyncRunner = new AsyncFacebookRunner(facebook); SessionStore.restore(facebook, context); SessionEvents.addAuthListener(mSessionListener); SessionEvents.addLogoutListener(mSessionListener); this.context = context; this.permissions = permissions; this.activity = activity; } public void login() { if (!facebook.isSessionValid()) { facebook.authorize(this.activity, this.permissions, new LoginDialogListener()); } } public void getID() { login(); return; } public boolean isSession() { sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); String access_token = sharedPrefs.getString("access_token", "x"); Long expires = sharedPrefs.getLong("access_expires", -1); Log.d(TAG, access_token); facebook.setAccessToken(null); facebook.setAccessExpires(-1); if (access_token != null && expires != -1) {
Can anybody help me?