While using facebook in Android to log in/register, it takes a while for facebook to send the request. Thus, how do I pause the activity(show a process dialog) till I get the facebook id/username of the user who is trying to register? I can’t do this in the base Listener as it is a background process.
I tried out using AsyncTask but I’m either confused how to do it or it can’t be done. Mostly the former. I did this:
public class FacebookOperation extends AsyncTask<Void, Void, Void>
{
@Override
protected void onPreExecute()
{
super.onPreExecute();
mFacebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
reg = "facebook";
SessionStore.restore(mFacebook, Register.this);
SessionEvents.addAuthListener(new SampleAuthListener());
//SessionEvents.addLogoutListener(new SampleLogoutListener());
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(Void result)
{
fillFormFb(); //Fills the form with the data from fb
}
@Override
protected Void doInBackground(Void... params) {
mLoginButton.init(Register.this, mFacebook,permissions);
return null;
}
}
Use AsyncTask to run your process in background.. you can show your progressbar while loading the operation.
}
EDIT
I think you can follow this link to integrate facebook with your app. It will helpful for you.
Hope it helps