Logs in automatically after first Facebook login

Hi, I am using the Backendless.UserService.loginWithFacebook() API and am having an issue where the facebook user is automatically being signed into my app on the second time they click the sign in with facebook. Is this the default behavior? If i want to sign in with a separate facebook account this doesn’t seem possible in this case.

I currently have a button that call the Backendless.UserService.loginWithFacebook() API as follows

facebookButton = (Button) findViewById(R.id.FBlogin_button);
facebookButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Map<String, String> facebookFieldMappings = new HashMap<String, String>() {{
put(“email”, “email”);
put(“gender”, “gender”);
put(“last_name”, “lname”);
put(“first_name”, “fname”);
put(“picture”, “picture”);
List<String> permissions = new ArrayList<>();
try {
Backendless.UserService.loginWithFacebook(MainActivity.this, null, facebookFieldMappings, permissions, new AsyncCallback<BackendlessUser>() {
public void handleResponse(BackendlessUser response) {
Person p = new Person();
p.setGender((String) response.getProperty(“gender”));
p.setLname((String) response.getProperty(“lname”));
p.setFname((String) response.getProperty(“fname”));
p.setFullname(response.getProperty(“fname”) + " " +
p.setEmail((String) response.getProperty(“email”));
try {
new Save(p, response).execute().get();
} catch (InterruptedException | ExecutionException e) {
public void handleFault(BackendlessFault fault) {
Toast.makeText(getApplicationContext(), fault.getMessage(), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(“YOUR_APP_LOG_TAG”, “I got an error”, e);

Since this is a login using Facebook SDK, I assume there would be something within their SDK that stores the user identity.

Use your own logic
if User Login first time save a boolean variable in Shared Preference.
Then On Start of Splash/Login or any Your Activity Which starts first, Check if Boolean is True (Which mean user already login) then skip the login and directly goto MainActivity else goto login.

P.S. Its Better when you Login with facebook save users all information e.g. id/name/ etc. for further use using shared Preference and its simple and easy to implement.

Sorry for the confusion but I’m not using the Facebook SDK which is loginWithFacebookSdk(…) Im using the loginWithFacebook which is the backendless SDK sign in?

@Asad Mehmood sorry for the confusion, but Im trying to prevent a user from automatically being signed in which seems to be the behavior of the method after a first successful sign in.


Sorry, but I am having hard time grasping the issue. Could you please describe it in a step-by-step way ?

Hi Mark,

I’m having this issue as well. What I’m doing is using the Easy Facebook Login, which doesn’t require the Facebook SDK on the client device. The problem is:

    Tap Facebook login button Login with John's Facebook account in the webview pop up Logged in Logout of Back endless Tap Facebook login button again Logged in with John's account without providing credentials again. (no web view)
It seems impossible for a different user to log in on the same device

Hi mark the issue is simply that after the first time an app user who has signed in to the app signs in again with the facebook sdk he/she is always logged back in without having to reenter credentials which means another user can never signin with facebook log in if it just authenticates them without the facebook widget popping up.

Hi guys,

This is exactly how the Facebook SDK login works:

Hi Sergey,

That may be but even in your SDK, “stay logged in” is false (off). So this shouldn’t be the default behaviour.

loginWithFacebook( context, webView, facebookFieldsMappings, permissions, responder, false );

I agree, setting stay ‘logged in’ to false would imply a user is not going to stay logged in when app closes.

If the stayloggedin parameter does or does not keep a user logged in then im curious what it actually does.

The links you provided may apply more to a web browser scenarios?

Also, the user shouldn’t be logged in again if he has explicitly logged out. The stayLoggedIn should only apply when the user exits/terminates the app without logging out.