[英]Button Logout for android facebook connect
Need Help - I have some code for Logout like this 需要帮助-我有一些这样的注销代码
public void logoutFromFacebook() {
mAsyncRunner.logout(this, new RequestListener() {
public void onComplete(String response, Object state) {
Log.d("Logout from Facebook", response);
if (Boolean.parseBoolean(response) == true) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Login button visible
btnFbLogin.setVisibility(View.VISIBLE);
// making all remaining buttons invisible
btnFbGetProfile.setVisibility(View.INVISIBLE);
btnPostToWall.setVisibility(View.INVISIBLE);
btnShowAccessTokens.setVisibility(View.INVISIBLE);
btnFbLogout.setVisibility(View.INVISIBLE);
}
});
}
}
}
But that code didnt work , when I click logout , and click login again , Im not input username and password again , I want if i click logout and when i click login again , i can input username and password again , Pleasee need solution , thanks 但是该代码不起作用,当我单击注销,然后再次单击登录时,我不再输入用户名和密码,我想如果我单击注销,当我再次单击登录时,我可以再次输入用户名和密码,请解决方案,谢谢
You have to use like this way when user press logout button you have to execute this code 当用户按下注销按钮时,您必须使用这种方式来执行此代码
public void runTestLogout() {
if (testLogout()) {
logoutText.setText("Logout Tests Passed");
} else {
logoutText.setText("Logout Tests Failed");
}
}
public boolean testLogout() {
try {
Log.d("Tests", "Testing logout");
String response = authenticatedFacebook.logout(this);
Log.d("Tests", "Got logout response: *" + response + "*");
if (!response.equals("true")) {
return false;
}
Log.d("Tests", "Testing logout on logged out facebook session");
try {
Util.parseJson(authenticatedFacebook.logout(this));
return false;
} catch (FacebookError e) {
if (e.getErrorCode() != 101 ||
!e.getMessage().equals("Invalid API key") ) {
return false;
}
}
Log.d("Tests", "Testing logout on unauthenticated object");
try {
Util.parseJson(new Facebook(APP_ID).logout(this));
return false;
} catch (FacebookError e) {
if (e.getErrorCode() != 101 ||
!e.getMessage().equals("Invalid API key") ) {
return false;
}
}
Log.d("Tests", "All Logout Tests Passed");
return true;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
The main thing is 最主要的是
String response = authenticatedFacebook.logout(this);
by running this code you will be logout now you can again log in and you will get empty username and password button 通过运行此代码,您将立即注销,您可以再次登录,并且将获得空的用户名和密码按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.