Facebook SDK for android - How to share Session throughout all activities
A problem which I faced when using Facebook SDK for android was in my app login happens through one activity and posting to Facebook happens through another activity. So I had to retrieve the session which is opened in the LoginActitvity. Actually solution was simpler than I thought. To get the session from an another activity you can use the below method.
private void getSession() { Session.openActiveSession(this, false, callback); } private Session.StatusCallback callback = new Session.StatusCallback() { public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { //Do something } } };
Comments
Post a Comment