Reputation: 121
I'm following the android facebook tutorial at: http://developers.facebook.com/docs/mobile/android/build/
I'm at step 7, adding a button to logout. The tutorial provides sample code, however I have a few questions:
Where should I be putting the sample code provided? In the event handler of a button I need to create? In the onCreate function?
Do I need to write bodies for the five empty functions or are they there for some other purpose?
Where should the mAsyncRunner object be instantiated?
All help is appreciated!
Upvotes: 1
Views: 4433
Reputation: 5979
dude try this
public void onClick(View arg0) {
if (mFb.isSessionValid()) {
SessionEvents.onLogoutBegin();
AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(mFb);
asyncRunner.logout(getContext(), new LogoutRequestListener());
} else {
mFb.authorize(mActivity, mPermissions, mActivityCode, new LoginDialogListener());
}
}
if you get error let me know
Upvotes: 0
Reputation: 707
You need to put the AsyncRunner in the onClick event of a button so:
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mAsyncRunner.logout(blah, blah, blah);
}
});
The empty functions like OnComplete(), OnFacebookError(), etc are called accordingly after a user presses your logout button. So for example, when the user hits Logout you could display a progress dialog that says "Logging out" and in your OnComplete() function you could dismiss this dialog. Basically, it provides you with hooks to handle different events of "logging out".
This should be done somewhere in onCreate().
Take a look at the Hackbook example project, it helped me a lot.
Upvotes: 2