[英]how to logout using facebook api in android
i am using facebook api for android using facebook developer guide. 我正在使用Facebook开发人员指南为Android使用Facebook API。 I was able to implement the login for facebook api for android.
我能够为Android的Facebook API实现登录。 I want to implement logout function.
我想实现注销功能。 I have tried following developers guide, but have no idea which place exactly i have to implement.
我尝试按照开发人员指南进行操作,但是不知道我必须在哪个位置实施。 I will be grateful if u guys cud help me out below is the code.
如果你们伙计帮我解决下面的代码,我将不胜感激。
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);
}
}
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;
}
from: https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java 来自: https : //github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java
facebook.logout(mainActivityContex);
or 要么
facebook.logout(this);
in Facebook SDK Facebook.java --` 在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;
}`
使用3.1 SDK可以调用Session.getActiveSession()。closeAndClearTokenInformation()
There's a .logout() method on that Facebook class if I remember correctly. 如果我没记错的话,该Facebook类上有一个.logout()方法。 I think you're looking for that.
我认为您正在寻找。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.