当前位置: 首页>>代码示例>>Java>>正文


Java Session类代码示例

本文整理汇总了Java中com.facebook.Session的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Session类属于com.facebook包,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logout

import com.facebook.Session; //导入依赖的package包/类
public static void logout(Context ctx){
    userFacebookAccessToken = null;

    if (Session.getActiveSession() != null)
    {
        Session.getActiveSession().closeAndClearTokenInformation();
    }
    else
    {
        if (DEBUG) Timber.e("getActiveSessionIsNull");
        Session session = Session.openActiveSessionFromCache(ctx);

        if (session != null)
            session.closeAndClearTokenInformation();
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:17,代码来源:BFacebookManager.java

示例2: getUserFriendList

import com.facebook.Session; //导入依赖的package包/类
public static  Promise<List<GraphUser>, BError, Void>  getUserFriendList(){

        final Deferred<List<GraphUser>, BError, Void> deferred = new DeferredObject<>();

        
        if (!Session.getActiveSession().getState().isOpened())
        {
            return deferred.reject(new BError(BError.Code.SESSION_CLOSED));
        }
        Request req = Request.newMyFriendsRequest(Session.getActiveSession(), new Request.GraphUserListCallback() {
            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                deferred.resolve(users);
            }
        });

        req.executeAsync();
        
        return deferred.promise();
    }
 
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:21,代码来源:BFacebookManager.java

示例3: openSession

import com.facebook.Session; //导入依赖的package包/类
private void openSession(String applicationId, List<String> permissions,
        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);
            }
        }
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:23,代码来源:FacebookFragment.java

示例4: createRequest

import com.facebook.Session; //导入依赖的package包/类
private Request createRequest(String userID, Set<String> extraFields, Session session) {
    Request request = Request.newGraphPathRequest(session, userID + "/friends", null);

    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[]{
            ID,
            NAME
    };
    fields.addAll(Arrays.asList(requiredFields));

    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
        fields.add(pictureField);
    }

    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);

    return request;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:22,代码来源:FriendPickerFragment.java

示例5: startLogin

import com.facebook.Session; //导入依赖的package包/类
private void startLogin(GraphUser user, Session session) {
    try {
        loginMode = true;
        Fragment fragment = new FragmentSignIn();
        Bundle args = new Bundle();
        args.putInt(FragmentSignIn.LOGIN_MODE_ARG, LoginActivity.Mode.FACEBOOK.ordinal());
        args.putString(FragmentSignIn.LOGIN_PASSWORD_OR_TOKEN_ARG, session.getAccessToken());
        args.putString(FragmentSignIn.LOGIN_USERNAME_ARG, (String) user.getProperty("email"));
        fragment.setArguments(args);
        getChildFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, "tag").setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();

        Analytics.SocialTimeline.login();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:17,代码来源:FragmentSocialTimeline.java

示例6: requestUserData

import com.facebook.Session; //导入依赖的package包/类
public void requestUserData( Session session ) {
    // Request user data and show the results
    Request.newMeRequest(session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {
            if (user != null) {
               User currentUser = new User();
                currentUser.setUserId(user.getId());
                currentUser.setUserName(user.getUsername());
                currentUser.setFirstName(user.getFirstName());
                currentUser.setLastName(user.getLastName());
                currentUser.setDisplayName(user.getName());
                currentUser.setMail((String) user.getProperty("email"));
                currentUser.setProviderDisplayName("Facebook");
                currentUser.setProvider(PROVIDER_NAME);
               FbLoginDelegate.this.mUserHelper.setCurrentUser(currentUser);
                if ( mUserSessionCallback != null) {
                    mUserSessionCallback.onLogin();
                }
            }
        }
    }).executeAsync();
}
 
开发者ID:alessandrogurgel,项目名称:pedefacil,代码行数:25,代码来源:FbLoginDelegate.java

示例7: onSessionStateChange

import com.facebook.Session; //导入依赖的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

示例8: ensureOpenSession

import com.facebook.Session; //导入依赖的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: sendRequestDialog

import com.facebook.Session; //导入依赖的package包/类
private void sendRequestDialog() {

      Bundle params = new Bundle();
      params.putString("title", "Solicitação de Aplicativo");
      params.putString("message", "Experimente o IPRJapp");
      params.putString("link","https://play.google.com/store/apps/details?id=com.wb.goog.batman.brawler2013");
      params.putString("data",
          "{\"badge_of_awesomeness\":\"1\"," +
          "\"social_karma\":\"5\"}");  

      WebDialog requestsDialog = (
          new WebDialog.RequestsDialogBuilder(this.getActivity(), Session.getActiveSession(), params))
              .setOnCompleteListener(new OnCompleteListener() {

                  @Override
                  public void onComplete(Bundle values, FacebookException error) {
                  }

              })
              .build();
      requestsDialog.show();
  }
 
开发者ID:Paulocajr,项目名称:IPRJapp,代码行数:23,代码来源:Left_Menu.java

示例10: updateView

import com.facebook.Session; //导入依赖的package包/类
private void updateView() {
	Session session = Session.getActiveSession();
	if (session.isOpened()) {
		makeMeRequest();
		// textInstructionsOrLink.setText(URL_PREFIX_FRIENDS +
		// session.getAccessToken());

		// buttonLoginLogout.setText("Logout");
		// buttonLoginLogout.setOnClickListener(new OnClickListener() {
		// public void onClick(View view) { onClickLogout(); }
		// });
	} else {
		onClickLogin();
		// textInstructionsOrLink.setText("Please login");
		// buttonLoginLogout.setText("Login");
		// buttonLoginLogout.setOnClickListener(new OnClickListener() {
		// public void onClick(View view) { onClickLogin(); }
		// });
	}
	
}
 
开发者ID:ohmp,项目名称:UniversalSocialLoginAndroid,代码行数:22,代码来源:FacebookLoginActivity.java

示例11: connect

import com.facebook.Session; //导入依赖的package包/类
@Override
public void connect(Activity activity)
{
	Session session = Session.getActiveSession();

	// TODO: I think we should validate the session here, but to what
	// extent?

	MadFacebookStatusCallback statusCallback =
			new MadFacebookStatusCallback();

	// Check if the session is already open.
	if (!session.isOpened() && !session.isClosed())
	{
		OpenRequest openRequest = new OpenRequest(activity);
		session.openForRead(openRequest
				.setCallback(statusCallback));
	}
	else
	{
		Session.openActiveSession(activity, true,
				statusCallback);
	}

}
 
开发者ID:netanelkl,项目名称:guitar_guy,代码行数:26,代码来源:FacebookProfileConnector.java

示例12: populateContact

import com.facebook.Session; //导入依赖的package包/类
public void populateContact() {
    final Session session = Session.getActiveSession();
    new Request(session, "/me/friends", null, HttpMethod.GET,
            new Request.Callback() {
                public void onCompleted(Response response) {

                    // Process the returned response
                    GraphObject graphObject = response.getGraphObject();
                    if (graphObject != null) {
                        // Check if there is extra data
                        if (graphObject.getProperty("data") != null) {
                                JSONArray arrayObject = (JSONArray) graphObject
                                        .getProperty("data");

                                int count = arrayObject.length();
                                if(count == 0)
                                    hasAppFriends = false;
                                // Ensure the user has at least one friend
                                //session.close();
                        }
                    }
                }

            }).executeAsync();
}
 
开发者ID:3bytessolutions,项目名称:CallService-Facebook-sample,代码行数:26,代码来源:UserHome.java

示例13: SessionTracker

import com.facebook.Session; //导入依赖的package包/类
/**
 * Constructs a SessionTracker to track the Session object passed in.
 * If the Session is null, then it will track the active Session instead.
 * 
 * @param context the context object.
 * @param callback the callback to use whenever the Session's state changes
 * @param session the Session object to track
 * @param startTracking whether to start tracking the Session right away
 */
public SessionTracker(Context context, Session.StatusCallback callback, Session session, boolean startTracking) {
    this.callback = new CallbackWrapper(callback);
    this.session = session;
    this.receiver = new ActiveSessionBroadcastReceiver();
    this.broadcastManager = LocalBroadcastManager.getInstance(context);

    if (startTracking) {
        startTracking();
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:20,代码来源:SessionTracker.java

示例14: getOpenSession

import com.facebook.Session; //导入依赖的package包/类
/**
 * Returns the current Session that's being tracked if it's open, 
 * otherwise returns null.
 * 
 * @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;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:14,代码来源:SessionTracker.java

示例15: setSession

import com.facebook.Session; //导入依赖的package包/类
/**
 * 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
            // 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);
            }
            broadcastManager.unregisterReceiver(receiver);
        } else {
            // We're currently tracking a Session, but are now switching 
            // to a new Session, so we remove the callback from the old 
            // Session, and add it to the new one.
            session.removeCallback(callback);
        }
        session = newSession;
        session.addCallback(callback);
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:37,代码来源:SessionTracker.java


注:本文中的com.facebook.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。