Question

I am developing an application in which i want to login via facebook. What I done is:

After splash screen a login screen is there on which user name and password edit text are there. After entering the credential on clicking on face book login button the user should authenticate from face book in background. If the user is authenticated then he directly goes on next activity else toast message should pop up.

I had done some code in .java as :

public class LoginScreenActivity extends Activity {
/** Global Variable Declaration. */
int nextMoveFlage = 0;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_layout);
            // start Facebook Login
    Session.openActiveSession(this, true, new Session.StatusCallback() {
        // callback when session changes state
        @Override
        public void call(Session session, SessionState state,Exception exception) {
            if (session.isOpened()) {
                // make request to the /me API
                Request.executeMeRequestAsync(session,new Request.GraphUserCallback() {
                    // callback after Graph API response with user object
                    @Override
                    public void onCompleted(GraphUser user,Response response) {
                        if (user != null) {
                            TextView welcome = (TextView) findViewById(R.id.textview_hello);
                            welcome.setText("Hello "+ user.getName() + "!");
                            //Intent intent = new Intent(LoginScreenActivity.this,NextScreen.class);
                            //startActivity(intent);
                        }
                    }
                });
            }
        }
    });
}

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Session.getActiveSession().onActivityResult(this, requestCode,resultCode, data);
    }
}

I also created app in my face book console and added all information such as Key Hash, Package Name, etc. And copy that app id in my String.XML file.

Added metadata in manifest file for app id.

The issue is that :

  1. I am not able to move on next activity after login as how to move or where to write intent code.

  2. Is the face app (SDK) is necessary to run my app. If any one is not having facebook SDK than what is the solution.

  3. Some times i got an error as remote_app_id does not match stored id But i copied the app id from face book console itself.

Please guide me on my issues and give your valuable suggetions.

Was it helpful?

Solution

  1. You should put the intent to start the next activity in your session status callback (inside the if(Session.isOpened()) check, where you're currently executing a "me" request.

  2. The SDK is necessary to run your app, but not the Facebook app. The SDK is included (and bundled) with your apk, the Facebook app is a separate apk, and is not required for log in with Facebook.

  3. If you get that error, that means you don't have the right key hashes in your settings. Did you sign using a different keystore?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top