Java Code Examples for com.facebook.Session#openActiveSession()

The following examples show how to use com.facebook.Session#openActiveSession() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FacebookContactMatcher.java    From buddycloud-android with Apache License 2.0 6 votes vote down vote up
protected void authFB(final Activity activity, 
		final ModelCallback<JSONArray> callback) {
	Session.openActiveSession(activity, true,
			new Session.StatusCallback() {
		@Override
		public void call(Session session, SessionState state,
				Exception exception) {
			if (exception != null) {
				callback.error(exception);
				return;
			}
			if (session.isOpened()) {
				getFriends(activity, session, callback);
			}
		}
	});
}
 
Example 2
Source File: HypFacebookFrag.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
*
*
* @public
* @return	void
*/
public void authorize( ){
	trace("authorize");
	Session session = Session.getActiveSession();
       if (!session.isOpened() && !session.isClosed() ) {
           session.openForRead( new Session.OpenRequest(this).setCallback( callback ) );
       } else {
           Session.openActiveSession( getActivity( ), this , true , callback );
       }

}
 
Example 3
Source File: SessionLoginFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private void onClickLogin() {
    Session session = Session.getActiveSession();
    if (!session.isOpened() && !session.isClosed()) {
        session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
    } else {
        Session.openActiveSession(getActivity(), this, true, statusCallback);
    }
}
 
Example 4
Source File: LoginUsingActivityActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private void onClickLogin() {
    Session session = Session.getActiveSession();
    if (!session.isOpened() && !session.isClosed()) {
        session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
    } else {
        Session.openActiveSession(this, true, statusCallback);
    }
}
 
Example 5
Source File: FriendPickerSampleActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private boolean ensureOpenSession() {
    if (Session.getActiveSession() == null ||
            !Session.getActiveSession().isOpened()) {
        Session.openActiveSession(this, true, new Session.StatusCallback() {
            @Override
            public void call(Session session, SessionState state, Exception exception) {
                onSessionStateChanged(session, state, exception);
            }
        });
        return false;
    }
    return true;
}
 
Example 6
Source File: PlacePickerSampleActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private boolean ensureOpenSession() {
    if (Session.getActiveSession() == null ||
            !Session.getActiveSession().isOpened()) {
        Session.openActiveSession(this, true, new Session.StatusCallback() {
            @Override
            public void call(Session session, SessionState state, Exception exception) {
                onSessionStateChanged(session, state, exception);
            }
        });
        return false;
    }
    return true;
}
 
Example 7
Source File: LoginFragment.java    From barterli_android with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(final View v) {

    switch (v.getId()) {

        case R.id.button_facebook_login: {
            GoogleAnalyticsManager
                    .getInstance()
                    .sendEvent(new EventBuilder(Categories.CONVERSION, Actions.SIGN_IN_ATTEMPT)
                                       .set(ParamKeys.TYPE, ParamValues.FACEBOOK));
            final Session session = Session.getActiveSession();
            if (!session.isOpened() && !session.isClosed()) {
                session.openForRead(new Session.OpenRequest(this)
                                            .setPermissions(Arrays
                                                                    .asList(AppConstants
                                                                                    .FBPERMISSIONS))
                                            .setCallback(this));
            } else {
                Session.openActiveSession(getActivity(), this, true, this);
            }
            break;
        }

        case R.id.button_google_login: {
            GoogleAnalyticsManager
                    .getInstance()
                    .sendEvent(new EventBuilder(Categories.CONVERSION, Actions.SIGN_IN_ATTEMPT)
                                       .set(ParamKeys.TYPE, ParamValues.GOOGLE));
            ((AuthActivity) getActivity()).getPlusManager().login();
            break;
        }

        case R.id.button_submit: {
            if (isInputValid()) {
                GoogleAnalyticsManager
                        .getInstance()
                        .sendEvent(
                                new EventBuilder(Categories.CONVERSION, Actions.SIGN_IN_ATTEMPT)
                                        .set(ParamKeys.TYPE, ParamValues.EMAIL)
                        );
                login(mEmailEditText.getText().toString(), mPasswordEditText
                        .getText().toString());
            }
            break;
        }

        case R.id.forgot_password: {
            showForgotPasswordDialog();

        }
    }
}
 
Example 8
Source File: HypFacebookFrag.java    From HypFacebook with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
*
*
* @public
* @return	void
*/
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	_sAppID			= getArguments().getString( APP_ID );
	_aPermissions	= Arrays.asList( getArguments().getString( APP_PERMS ).split("&"));

	trace("onCreate");


      	//_authorize( );



       uiHelper = new UiLifecycleHelper(getActivity( ), callback);
      	uiHelper.onCreate(savedInstanceState);

      	_session = Session.getActiveSession();
       if (!_session.isOpened() && !_session.isClosed() ) {
           _session.openForRead( new Session.OpenRequest(this).setCallback( callback ) );
       } else {
           Session.openActiveSession( getActivity( ), this , true , callback );
       }
}