I am new to Android. I am using fbrocket example for status post for my application, but I cannot log out from my application. Status message will be posted successfully from this application, but When I close my application, I want to also log out from Facebook.
How can i do this?
Please help me.
My code is here:
package com.drc.Incognito;
import net.xeomax.FBRocket.FBRocket;
import net.xeomax.FBRocket.LoginListener;
import net.xeomax.FBRocket.ServerErrorException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Facebook extends Activity implements LoginListener {
private FBRocket fbRocket;
Bundle bundle;
int i;
String rname,rshopno,raddress,rcity,rphone,remail,rpostcode;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
rname=bundle.getString("keyshop_name");
rshopno=bundle.getString("keyshop_no");
raddress=bundle.getString("keystreet");
rpostcode=bundle.getString("keypostcode");
rcity=bundle.getString("keycity");
rphone=bundle.getString("keyphone");
remail=bundle.getString("keyemail");
shareFacebook();
}
public void shareFacebook() {
fbRocket = new FBRocket(this, "PitchFork TRY",
"c3968bbdd9dc7f44a8e05b7346f46673");
if (fbRocket.existsSavedFacebook()) {
fbRocket.loadFacebook();
} else {
fbRocket.login(R.layout.main);
}
}
@Override
public void onLoginFail() {
fbRocket.displayToast("Login failed!");
fbRocket.login(R.layout.main);
}
@Override
public void onLoginSuccess(net.xeomax.FBRocket.Facebook facebook) {
// TODO Auto-generated method stub
try {
System.out.println("Incognito Shop: " +"\n" +rname +"\n" +raddress+ " " + rshopno +"\n" +rpostcode + " " +rcity + "\n" +rphone +"\n" + remail);
fbRocket.displayToast("Login success!");
facebook.setStatus("Incognito Shop: " +"\n" +rname +"\n" +raddress+ " " + rshopno +"\n" +rpostcode + " " +rcity + "\n" +rphone +"\n" + remail);
fbRocket.displayDialog("Status Posted Successfully!! ");
// Intent in = new Intent(this,ShopDetail.class);
// startActivity(in);
facebook.logout();
finish();
} catch (ServerErrorException e) {
if (e.notLoggedIn()) {
fbRocket.login(R.layout.main);
} else {
System.out.println(e);
}
}
}
}
Can you tell me how can I log out from my application when I close my application?
Actually these applications are one-click go applications, so they require username and password only once. Then these application stores them in their private files, so whenever next time the application launches, the user is logged in automatically. This facility is given since the device on which they are using are personal, so no need to logout. But if you want to log out the application, the only way is Clear the data.. Go to
Settings -> Applications -> Manage Application -> Select Application -> Clear Data.