I have an android app in which i am using Facebook Android SDK to post content from my application to Facebook Wall. My code was working perfectly till i updated the Facebook app on my phone. Since that time, whenever i try to post content on Facebook, i get the login screen with the "Loading" option and after a few seconds, nothing happens. Here is the code which i am using
On Facebook Button CLick
if(isOnline())
{
mFacebook = new Facebook("APP ID");
mFacebook.authorize(this,new String[] {"publish_stream", "read_stream", "offline_access"}, new AuthorizeListener());
}
The Code for Authorize listener is
class AuthorizeListener implements DialogListener {
public void onComplete(Bundle values) {
// Handle a successful login
postOnWall("My wall text")开发者_JS百科;
}
@Override
public void onCancel() {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onFacebookError(FacebookError e) {
}
}
After debugging i found that the OnComplete method is not being called after calling the authorize function and there is also no exception. This was working perfectly till i update the Facebook app on my Android phone.
Any help will be appreciated
Make sure you are calling Facebook.authorizeCallback
in your Activity's onActivityResult
:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
// ... anything else your app does onActivityResult ...
}
For the details, carefully read this page.
精彩评论