我使用facebook开发者指南使用facebook api for android。我能够实现facebook api for android的登录。我想实现注销功能。我试过跟随开发者指南,但不知道我必须实现哪个地方。如果你们帮我解决下面的代码,我将不胜感激。
public class FacebookandroidsdkActivity extends Activity {
/** Called when the activity is first created. */
Facebook facebook = new Facebook("252039928190210");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
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() {}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
}
答案 0 :(得分:6)
public String logout(Context context)
throws MalformedURLException, IOException {
Util.clearCookies(context);
Bundle b = new Bundle();
b.putString("method", "auth.expireSession");
String response = request(b);
setAccessToken(null);
setAccessExpires(0);
return response;
}
答案 1 :(得分:6)
facebook.logout(mainActivityContex);
或
facebook.logout(this);
在Facebook SDK中Facebook.java --`
public String logout(Context context)
throws MalformedURLException, IOException {
Util.clearCookies(context);
Bundle b = new Bundle();
b.putString("method", "auth.expireSession");
String response = request(b);
setAccessToken(null);
setAccessExpires(0);
return response;
}`
答案 2 :(得分:1)
可以调用Session.getActiveSession()。closeAndClearTokenInformation()
答案 3 :(得分:0)
如果我没记错的话,那个Facebook类上有一个.logout()方法。我想你正在寻找那个。