本文整理汇总了Java中com.facebook.Session.openForRead方法的典型用法代码示例。如果您正苦于以下问题:Java Session.openForRead方法的具体用法?Java Session.openForRead怎么用?Java Session.openForRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.Session
的用法示例。
在下文中一共展示了Session.openForRead方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: fetchProfileInfoFromFacebook
import com.facebook.Session; //导入方法依赖的package包/类
/**
* Fetch profile information from Facebook
*/
private void fetchProfileInfoFromFacebook() {
mWasProfileImageUploaded = false;
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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: openSession
import com.facebook.Session; //导入方法依赖的package包/类
private void openSession(Session session, Session.OpenRequest openRequest, boolean isPublish) {
openRequest.setIsLegacy(true);
if (isPublish) {
session.openForPublish(openRequest);
} else {
session.openForRead(openRequest);
}
}
示例6: onClickLogin
import com.facebook.Session; //导入方法依赖的package包/类
private void onClickLogin() {
Session session = Session.getActiveSession();
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(this).setPermissions(
Arrays.asList("email","user_birthday")).setCallback(this));
} else {
Session.openActiveSession(this, true, this);
}
}
示例7: 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);
}
}
示例8: onClick
import com.facebook.Session; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
Context context = getContext();
final Session openSession = sessionTracker.getOpenSession();
if (openSession != null) {
// If the Session is currently open, it must mean we need to log out
if (confirmLogout) {
// Create a confirmation dialog
String logout = getResources().getString(R.string.com_facebook_loginview_log_out_action);
String cancel = getResources().getString(R.string.com_facebook_loginview_cancel_action);
String message;
if (user != null && user.getName() != null) {
message = String.format(getResources().getString(R.string.com_facebook_loginview_logged_in_as), user.getName());
} else {
message = getResources().getString(R.string.com_facebook_loginview_logged_in_using_facebook);
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(message)
.setCancelable(true)
.setPositiveButton(logout, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
openSession.closeAndClearTokenInformation();
}
})
.setNegativeButton(cancel, null);
builder.create().show();
} else {
openSession.closeAndClearTokenInformation();
}
} else {
Session currentSession = sessionTracker.getSession();
if (currentSession == null || currentSession.getState().isClosed()) {
sessionTracker.setSession(null);
Session session = new Session.Builder(context).setApplicationId(applicationId).build();
Session.setActiveSession(session);
currentSession = session;
}
if (!currentSession.isOpened()) {
Session.OpenRequest openRequest = null;
if (parentFragment != null) {
openRequest = new Session.OpenRequest(parentFragment);
} else if (context instanceof Activity) {
openRequest = new Session.OpenRequest((Activity)context);
}
if (openRequest != null) {
openRequest.setDefaultAudience(properties.defaultAudience);
openRequest.setPermissions(properties.permissions);
openRequest.setLoginBehavior(properties.loginBehavior);
if (SessionAuthorizationType.PUBLISH.equals(properties.authorizationType)) {
currentSession.openForPublish(openRequest);
} else {
currentSession.openForRead(openRequest);
}
}
}
}
AppEventsLogger logger = AppEventsLogger.newLogger(getContext());
Bundle parameters = new Bundle();
parameters.putInt("logging_in", (openSession != null) ? 0 : 1);
logger.logSdkEvent(loginLogoutEventName, null, parameters);
}