如何在Android中使用Facebook API登出
我正在使用Facebook开发人员指南为Android使用Facebook API。我能够为Android的Facebook
API实现登录。我想实现注销功能。我尝试按照开发人员指南进行操作,但是不知道我必须在哪个位置实施。如果您能帮助我,下面将提供代码,我将不胜感激。
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);
}
}
回答:
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;
}`
以上是 如何在Android中使用Facebook API登出 的全部内容, 来源链接: utcz.com/qa/427348.html