Android Session - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Session class.

This code example shows how to use the following methods:isOpened, openForPublish, openForRead, setActiveSession
            SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) { 
        if (sessionTracker != null) { 
            Session currentSession = sessionTracker.getSession(); 
            if (currentSession == null || currentSession.getState().isClosed()) { 
                Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build(); 
                Session.setActiveSession(session); 
                currentSession = session; 
            } 
            if (!currentSession.isOpened()) { 
                Session.OpenRequest openRequest = new Session.OpenRequest(this). 
                        setPermissions(permissions). 
                        setLoginBehavior(behavior). 
                        setRequestCode(activityCode); 
                if (SessionAuthorizationType.PUBLISH.equals(authType)) { 
                    currentSession.openForPublish(openRequest); 
                } else { 
                    currentSession.openForRead(openRequest); 
                } 
            } 
        } 

9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isOpened
     *  
     * @return the current Session if it's open, otherwise returns null 
     */ 
    public Session getOpenSession() {
        Session openSession = getSession();
        if (openSession != null && openSession.isOpened()) {
            return openSession;
        } 
        return null; 
    } 
 
    /** 
     * Set the Session object to track. 
     *  
     * @param newSession the new Session object to track 
     */ 
    public void setSession(Session newSession) {
        if (newSession == null) {
            if (session != null) {
                // We're current tracking a Session. Remove the callback 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:removeCallback
    public void setSession(Session newSession) {
        if (newSession == null) {
            if (session != null) {
                // We're current tracking a Session. Remove the callback 
                // and start tracking the active Session. 
                session.removeCallback(callback);
                session = null;
                addBroadcastReceiver(); 
                if (getSession() != null) {
                    getSession().addCallback(callback);
                } 
            } 
        } else { 
            if (session == null) {
                // We're currently tracking the active Session, but will be 
                // switching to tracking a different Session object. 
                Session activeSession = Session.getActiveSession();
                if (activeSession != null) {
                    activeSession.removeCallback(callback);
                } 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:performClick, setReadPermissions, setSession, getPermissions
                new SessionTestsBase.SessionStatusCallbackRecorder(); 
 
        // Verify state with no token in cache 
        assertEquals(SessionState.CREATED, session.getState());
 
        final LoginButton button = new LoginButton(getActivity());
        button.setSession(session);
        session.addAuthorizeResult("A token of thanks",
                Arrays.asList(new String[] {"read_permission", "read_another"}), AccessTokenSource.TEST_USER);
        session.addCallback(statusRecorder);
 
        button.performClick();
 
        statusRecorder.waitForCall(session, SessionState.OPENING, null);
        statusRecorder.waitForCall(session, SessionState.OPENED, null);
 
        // this should be fine 
        button.setReadPermissions(Arrays.asList(new String[] {"read_permission", "read_another"}));
 
        button.setReadPermissions(Arrays.asList(new String[] {"read_permission", "read_a_third"}));

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAccessToken, getApplicationId, isOpened

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getPermissions, toString
			Intent intent = (Intent) map.get(INTENT_KEY);
			startActivity(intent);
        	 
        } else { 
        	 
        	Session session = new Session(this);
        	 
        	Log.i("tag", session.toString());
        	 
        	 
        		if (!session.getPermissions().toString().equals("[]")) {
        	      	 
        			ServerRequest servReq = new ServerRequest(this);
        			servReq.fetchIDs(currUser);
        		} else { 
        			 
        			Toast.makeText(this, "Login with Facebook in the settings menu first", Toast.LENGTH_SHORT).show();
        		} 
 
        } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setActiveSession
		} 
		return true; 
	} 
 
	private void onSessionStateChanged(Session session, SessionState state,
			Exception exception) {
		if (pickFriendsWhenSessionOpened && state.isOpened()) {
			pickFriendsWhenSessionOpened = false;
 
			startPickFriendsActivity(); 
		} 
	} 
 
	private void displaySelectedFriends(int resultCode) {
		String results = "";
		FriendPickerApplication application = (FriendPickerApplication) getApplication();
 
		Collection<GraphUser> selection = application.getSelectedUsers();
		if (selection != null && selection.size() > 0) {
			ArrayList<String> names = new ArrayList<String>();
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:removeCallback
    public void setSession(Session newSession) {
        if (newSession == null) {
            if (session != null) {
                // We're current tracking a Session. Remove the callback 
                // and start tracking the active Session. 
                session.removeCallback(callback);
                session = null;
                addBroadcastReceiver(); 
                if (getSession() != null) {
                    getSession().addCallback(callback);
                } 
            } 
        } else { 
            if (session == null) {
                // We're currently tracking the active Session, but will be 
                // switching to tracking a different Session object. 
                Session activeSession = Session.getActiveSession();
                if (activeSession != null) {
                    activeSession.removeCallback(callback);
                } 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:open, setActiveSession
				// defaults on other values 
				AccessToken accessToken = AccessToken
						.createFromExistingAccessToken(access_token, null,
								null, null, null); 
				// statusCallback: Session.StatusCallback implementation 
				fbSession.open(accessToken, null);
				Session.setActiveSession(fbSession);
			} 
		} 
		return fbSession;
	} 
 
	// public AsyncFacebookRunner getAsyncFacebookRunner() { 
	// if (mAsyncFacebookRunner == null) { 
	// mAsyncFacebookRunner = new AsyncFacebookRunner(getFacebook()); 
	// } 
	// return mAsyncFacebookRunner; 
	// } 
 
	// public void extendFacebookTokenIfNeeded() { 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:requestNewPublishPermissions
	 
	private void requestPublishPermissions(Session session) {
		if (session != null) {
			Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(activity, PERMISSIONS)
					.setRequestCode(REAUTH_ACTIVITY_CODE);
			session.requestNewPublishPermissions(newPermissionsRequest);
		} 
	} 
	 
	private interface TaskGraphObject extends GraphObject {
		public String getUrl();
 
		public void setUrl(String url);
 
		public String getId();
 
		public void setId(String id);
	} 
	 
	private interface FinishAction extends OpenGraphAction {
3
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android Session Questions & Answers:

See Code Examples for Android Session Methods: