當前位置: 首頁>>代碼示例>>Java>>正文


Java SessionState類代碼示例

本文整理匯總了Java中com.facebook.SessionState的典型用法代碼示例。如果您正苦於以下問題:Java SessionState類的具體用法?Java SessionState怎麽用?Java SessionState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SessionState類屬於com.facebook包,在下文中一共展示了SessionState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: call

import com.facebook.SessionState; //導入依賴的package包/類
@Override
public void call(final Session session, SessionState state, Exception exception) {


    if (state.isOpened()) {
        final Map<String, String> params = new HashMap<String, String>(3);
        params.put(HttpConstants.ACCESS_TOKEN, session.getAccessToken());
        //TODO enable field when the permission is accepted
        params.put(HttpConstants.FIELDS, HttpConstants.FaceBookConstants.ID + "," +
                HttpConstants.FaceBookConstants.NAME + "," +
                HttpConstants.FaceBookConstants.BIO + "," +
                HttpConstants.FaceBookConstants.ABOUT);

        RetroCallback retroCallback;
        retroCallback = new RetroCallback(this);
        retroCallback.setRequestId(HttpConstants.ApiResponseCodes.GET_FACEBOOK_PROFILE);
        retroCallbackList.add(retroCallback);
        mProgressBar.setVisibility(View.VISIBLE);
        mFacebookApi.getFacebookProfile(params, retroCallback);
    }

}
 
開發者ID:yeloapp,項目名稱:yelo-android,代碼行數:23,代碼來源:EditProfileFragment.java

示例2: onSessionStateChange

import com.facebook.SessionState; //導入依賴的package包/類
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
	Log.i("SplashscreenActivity", "onSessionStateChange");
	Controller.getInstance().setSession(session);
	if(state.isOpened() && !mConnected){
		mConnected = true;
		session.refreshPermissions();
		List<String> permissions = session.getPermissions();
		Log.i("FACEBOOK_CONNECTION", "Logged in..." + permissions.toString());
		findViewById(R.id.authButton).setVisibility(View.GONE);
		findViewById(R.id.progressBar).setVisibility(View.VISIBLE);
		((ProgressWheel) findViewById(R.id.progressBar)).spin();
		Server.connect(session.getAccessToken());
	} else if(state.isClosed()) {
		mConnected = false;
		Log.i("FACEBOOK_CONNECTION", "Logged out...");
	}
}
 
開發者ID:theblindr,項目名稱:blindr,代碼行數:18,代碼來源:SplashscreenActivity.java

示例3: onSessionStateChange

import com.facebook.SessionState; //導入依賴的package包/類
/**
 * Changes the UI when an interaction with the Session object occurs with the user.
 * @param session       The current active Session.
 * @param sessionState  The current state of the active Session.
 * @param e             An Exception if there is one.
 */
private void onSessionStateChange(Session session, SessionState sessionState, Exception e) {
    if (sessionState == SessionState.OPENED) {
        Log.d(TAG, "Successful login!");
        new Request(session, "/me", null, HttpMethod.GET, new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
                JSONObject obj = response.getGraphObject().getInnerJSONObject();
                Log.d(TAG, "Got back " + obj + " from Facebook API.");
                UserSession.getInstance().setFacebookData(obj);
                getUserData();
            }
        }).executeAsync();
    } else if (e != null) { // handle exception

    }
}
 
開發者ID:danfang,項目名稱:house-devs,代碼行數:23,代碼來源:LoginFragment.java

示例4: call

import com.facebook.SessionState; //導入依賴的package包/類
@Override
public void call(Session session, SessionState state, Exception exception) {
	if (session.isOpened()) {
		setFacebookSession(session);
		// make request to the /me API
		Request.newMeRequest(session, new Request.GraphUserCallback() {

			// callback after Graph API response with user object
			@Override
			public void onCompleted(GraphUser user, Response response) {
				if (user != null) {
					Toast.makeText(LoginActivity.this,
							"Hello " + user.getName(), Toast.LENGTH_LONG)
							.show();
				}
			}
		}).executeAsync();
	}
}
 
開發者ID:jinman,項目名稱:snake-game-aws,代碼行數:20,代碼來源:LoginActivity.java

示例5: ensureOpenSession

import com.facebook.SessionState; //導入依賴的package包/類
private boolean ensureOpenSession() {
    if (Session.getActiveSession() == null
            || !Session.getActiveSession().isOpened()) {
        Session.openActiveSession(this, true, PERMISSIONS,
                new Session.StatusCallback() {
                    @Override
                    public void call(Session session, SessionState state,
                                     Exception exception) {
                        onSessionStateChanged(session, state, exception);
                    }
                });
        return false;
    }
    // friendPickerFragment.loadData(false);

    return true;
}
 
開發者ID:3bytessolutions,項目名稱:CallService-Facebook-sample,代碼行數:18,代碼來源:UserHome.java

示例6: onCreate

import com.facebook.SessionState; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	setContentView(R.layout.pick_friends_activity);

	lifecycleHelper = new UiLifecycleHelper(this,
			new Session.StatusCallback() {
				@Override
				public void call(Session session, SessionState state,
								 Exception exception) {
					onSessionStateChanged(session, state, exception);
				}
			});
	lifecycleHelper.onCreate(savedInstanceState);

	this.savedInstanceState = savedInstanceState;

	loadFriendPicketFragment();

	ensureOpenSession();

}
 
開發者ID:3bytessolutions,項目名稱:CallService-Facebook-sample,代碼行數:24,代碼來源:PickFriendsActivity.java

示例7: ensureOpenSession

import com.facebook.SessionState; //導入依賴的package包/類
private boolean ensureOpenSession() {
	if (Session.getActiveSession() == null
			|| !Session.getActiveSession().isOpened()) {
		Session.openActiveSession(this, true, PERMISSIONS,
				new Session.StatusCallback() {
					@Override
					public void call(Session session, SessionState state,
									 Exception exception) {
						onSessionStateChanged(session, state, exception);
					}
				});
		return false;
	}
	if(friendPickerFragment == null) {
		String test;
				test= "0";
	}
	//friendPickerFragment.loadData(false);

	return true;
}
 
開發者ID:3bytessolutions,項目名稱:CallService-Facebook-sample,代碼行數:22,代碼來源:PickFriendsActivity.java

示例8: ensureOpenSession

import com.facebook.SessionState; //導入依賴的package包/類
private boolean ensureOpenSession() {
	if (Session.getActiveSession() == null
			|| !Session.getActiveSession().isOpened()) {
		Session.openActiveSession(this, true, PERMISSIONS,
				new Session.StatusCallback() {
					@Override
					public void call(Session session, SessionState state,
									 Exception exception) {
						onSessionStateChanged(session, state, exception);
					}
				});
		return false;
	}
	makeMeRequest();
	return true;
}
 
開發者ID:3bytessolutions,項目名稱:CallService-Facebook-sample,代碼行數:17,代碼來源:FbLoginActivity.java

示例9: onSessionStateChange

import com.facebook.SessionState; //導入依賴的package包/類
@Override
protected void onSessionStateChange(Session session, SessionState state, Exception exception){
    final TextView txtUserDetails = (TextView) mCurrentView.findViewById(R.id.mapViewLoggedInUser);
    if (session != null && session.isOpened()) {
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    txtUserDetails.setText("Logged in as " + user.getName());
                    System.out.println("onSessionStateChange: LoadNotes: session is open. username:"+user.getName());
                }
            }
        });
        Request.executeBatchAsync(request);
    } else if (session.isClosed()) {
        txtUserDetails.setText("");
        System.out.println("onSessionStateChange: LoadNotes: session was closed.");
    }
}
 
開發者ID:ZanyGnu,項目名稱:GeoNote,代碼行數:21,代碼來源:MapViewFragment.java

示例10: onSessionStateChangeP

import com.facebook.SessionState; //導入依賴的package包/類
private void onSessionStateChangeP(Session session, SessionState state, Exception exception)
{
    if (session != null && session.isOpened()) {
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    LoggedInUser = user;
                }
            }
        });
        Request.executeBatchAsync(request);
    } else if (session.isClosed()) {
        LoggedInUser = null;
    }

    onSessionStateChange(session, state, exception);
}
 
開發者ID:ZanyGnu,項目名稱:GeoNote,代碼行數:20,代碼來源:BaseFacebookHandlerFragment.java

示例11: onSessionStateChange

import com.facebook.SessionState; //導入依賴的package包/類
protected void onSessionStateChange(Session session, SessionState state, Exception exception){
    if (session != null && session.isOpened()) {
        logAndShowOnScreen("\nLogged in. Getting user details.");
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    System.out.println("onSessionStateChange: LoadNotes: session is open. username:"+user.getName());

                    loadNotes(getActivity(), user.getId());
                }
            }
        });
        Request.executeBatchAsync(request);
    } else {
        logAndShowOnScreen("\nUser not already logged in.");
        System.out.println("onSessionStateChange: LoadNotes: session was closed.");
        loadNotes(getActivity(), getLoggedInUsername());
    }
}
 
開發者ID:ZanyGnu,項目名稱:GeoNote,代碼行數:22,代碼來源:SplashScreenFragment.java

示例12: setupFacebookConnect

import com.facebook.SessionState; //導入依賴的package包/類
public void setupFacebookConnect(Bundle savedInstanceState) {
	Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

	Session session = Session.getActiveSession();
	if (session == null) {
		if (savedInstanceState != null) {
			session = Session.restoreSession(this, null, statusCallback,
					savedInstanceState);
		}
		if (session == null) {
			session = new Session(this);
		}
		Session.setActiveSession(session);
		if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
			session.openForRead(new Session.OpenRequest(this)
					.setCallback(statusCallback));
		}
	}
}
 
開發者ID:pranavlathigara,項目名稱:rm-facebook-login,代碼行數:20,代碼來源:MainActivity.java

示例13: onSessionStateChange

import com.facebook.SessionState; //導入依賴的package包/類
private void onSessionStateChange(Session session, SessionState state, Exception exception)
{
	if (getView() != null)
	{
		if (state.isOpened())
		{
			authButton.setVisibility(View.GONE);
			progressBar.setVisibility(View.VISIBLE);
		}
		else if (state.isClosed())
		{
			authButton.setVisibility(View.VISIBLE);
			progressBar.setVisibility(View.GONE);
		}
	}
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:17,代碼來源:LoginFragment.java

示例14: onSessionStateChange

import com.facebook.SessionState; //導入依賴的package包/類
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
    // Si hacemos login o logout, el estado de la sesion cambiará, por lo que en esta función se controla y se muestra el fragment correspondiente en funcion de si la sesión esta abierta o cerrada.
    if (isResumed) {
        FragmentManager manager = getSupportFragmentManager();
        int backStackSize = manager.getBackStackEntryCount();
        for (int i = 0; i < backStackSize; i++) {
            manager.popBackStack();
        }
        // check for the OPENED state instead of session.isOpened() since for the
        // OPENED_TOKEN_UPDATED state, the selection fragment should already be showing.
        if (state.equals(SessionState.OPENED)) {
            if (Utilities.checkGooglePlayServiceAvailability(this)) {
                goToHome(session);
            }
        } else if (state.isClosed()) {
            showFragment(LOGIN, false);
        }
    }
}
 
開發者ID:pacomf,項目名稱:Shorcial,代碼行數:20,代碼來源:Inicio.java

示例15: fbLogin

import com.facebook.SessionState; //導入依賴的package包/類
public void fbLogin(Activity activity, final Runnable pCallback){
	Session.openActiveSession(activity, true, new Session.StatusCallback() {
		@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() {
					@Override
					public void onCompleted(GraphUser user, Response response) {
						mUser = user;
						
						if(pCallback != null)
							pCallback.run();
					}
				});
			}
		}
	});
}
 
開發者ID:DobrinAlexandru,項目名稱:Wabbit-Messenger---android-client,代碼行數:20,代碼來源:FBMgr.java


注:本文中的com.facebook.SessionState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。