本文整理汇总了Java中com.facebook.Session.isOpened方法的典型用法代码示例。如果您正苦于以下问题:Java Session.isOpened方法的具体用法?Java Session.isOpened怎么用?Java Session.isOpened使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.Session
的用法示例。
在下文中一共展示了Session.isOpened方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
}
示例2: onSessionStateChangeP
import com.facebook.Session; //导入方法依赖的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);
}
示例3: fetchUserInfo
import com.facebook.Session; //导入方法依赖的package包/类
private void fetchUserInfo() {
final Session currentSession = getSession();
if (currentSession != null && currentSession.isOpened()) {
if (currentSession != userInfoSession) {
Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser me, Response response) {
if (currentSession == getSession()) {
user = me;
updateUI();
}
if (response.getError() != null) {
loginButton.handleError(response.getError().getException());
}
}
});
Bundle parameters = new Bundle();
parameters.putString(FIELDS, REQUEST_FIELDS);
request.setParameters(parameters);
Request.executeBatchAsync(request);
userInfoSession = currentSession;
}
} else {
user = null;
}
}
示例4: populateLoggedInUser
import com.facebook.Session; //导入方法依赖的package包/类
private void populateLoggedInUser() {
final TextView txtUserDetails = (TextView) this.getActivity().findViewById(R.id.userDetails);
final Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
// If the session is open, make an API call to get user data
// and define a new callback to handle the response
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// If the response is successful
if (session == Session.getActiveSession()) {
if (user != null) {
String user_ID = user.getId();//user id
String profileName = user.getName();//user's profile name
txtUserDetails.setText(user.getName());
}
}
}
});
Request.executeBatchAsync(request);
} else if (session == null || session.isClosed()) {
}
}
示例5: onSessionStateChange
import com.facebook.Session; //导入方法依赖的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());
}
}
示例6: 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(); }
// });
}
}
示例7: 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);
}
}
示例8: 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;
}
示例9: loginError
import com.facebook.Session; //导入方法依赖的package包/类
public void loginError() {
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
session.closeAndClearTokenInformation();
}
loginMode = false;
init();
}
示例10: onResume
import com.facebook.Session; //导入方法依赖的package包/类
public void onResume() {
Session session = Session.getActiveSession();
if (session != null &&
(session.isOpened() || session.isClosed()) ) {
onSessionStateChange(session, session.getState(), null);
}
mUiHelper.onResume();
}
示例11: onClickLogin
import com.facebook.Session; //导入方法依赖的package包/类
public void onClickLogin() {
Session session = Session.getActiveSession();
if (!session.isOpened() && !session.isClosed()) {
Session.OpenRequest openRequest = new Session.OpenRequest(mContext);
openRequest.setPermissions(this.mPermissions);
openRequest.setCallback(this);
session.openForRead(openRequest);
} else {
Session.openActiveSession(mContext, true, this);
}
}
示例12: login
import com.facebook.Session; //导入方法依赖的package包/类
@Override
public void login() {
Session session = Session.getActiveSession();
if ( activity == null )
return;
if (session != null && !session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(activity)
.setPermissions(Arrays.asList("public_profile", "email"))
.setCallback(statusCallback));
} else {
Session.openActiveSession(activity, true, Arrays.asList("public_profile", "email"), statusCallback);
}
}
示例13: onActivityCreated
import com.facebook.Session; //导入方法依赖的package包/类
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
sessionTracker = new SessionTracker(getActivity(), new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (!session.isOpened()) {
// When a session is closed, we want to clear out our data so it is not visible to subsequent users
clearResults();
}
}
});
setSettingsFromBundle(savedInstanceState);
loadingStrategy = createLoadingStrategy();
loadingStrategy.attach(adapter);
selectionStrategy = createSelectionStrategy();
selectionStrategy.readSelectionFromBundle(savedInstanceState, SELECTION_BUNDLE_KEY);
// Should we display a title bar? (We need to do this after we've retrieved our bundle settings.)
if (showTitleBar) {
inflateTitleBar((ViewGroup) getView());
}
if (activityCircle != null && savedInstanceState != null) {
boolean shown = savedInstanceState.getBoolean(ACTIVITY_CIRCLE_SHOW_KEY, false);
if (shown) {
displayActivityCircle();
} else {
// Should be hidden already, but just to be sure.
hideActivityCircle();
}
}
}
示例14: onSessionChange
import com.facebook.Session; //导入方法依赖的package包/类
public void onSessionChange (Session session, SessionState sessionState, Exception e) {
if (session != null && session.isOpened()) {
// Está logueado
} else {
config.clear();
Intent intent = new Intent(Logout.this, LoginStep1.class);
startActivity(intent);
}
}
示例15: onActivityResumed
import com.facebook.Session; //导入方法依赖的package包/类
@Override
public void onActivityResumed(Activity activity) {
super.onActivityResumed(activity);
// For scenarios where the main activity is launched and user
// session is not null, the session state change notification
// may not be triggered. Trigger it if it's open/closed.
Session session = Session.getActiveSession();
if (session != null && (session.isOpened() || session.isClosed())) {
onSessionStateChange(session, session.getState(), null);
}
uiHelper.onResume();
}