本文整理汇总了Java中com.facebook.internal.WebDialog类的典型用法代码示例。如果您正苦于以下问题:Java WebDialog类的具体用法?Java WebDialog怎么用?Java WebDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebDialog类属于com.facebook.internal包,在下文中一共展示了WebDialog类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import com.facebook.internal.WebDialog; //导入依赖的package包/类
@Override
public WebDialog build() {
Bundle parameters = getParameters();
parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);
parameters.putString(
ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE,
ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN_AND_SIGNED_REQUEST);
parameters.putString(
ServerProtocol.DIALOG_PARAM_RETURN_SCOPES,
ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);
// Set the re-request auth type for requests
if (isRerequest) {
parameters.putString(
ServerProtocol.DIALOG_PARAM_AUTH_TYPE,
ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
}
return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
示例2: tryAuthorize
import com.facebook.internal.WebDialog; //导入依赖的package包/类
@Override
boolean tryAuthorize(final LoginClient.Request request) {
Bundle parameters = new Bundle();
if (!Utility.isNullOrEmpty(request.getPermissions())) {
String scope = TextUtils.join(",", request.getPermissions());
parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
}
DefaultAudience audience = request.getDefaultAudience();
parameters.putString(
ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());
AccessToken previousToken = AccessToken.getCurrentAccessToken();
String previousTokenString = previousToken != null ? previousToken.getToken() : null;
if (previousTokenString != null
&& (previousTokenString.equals(loadCookieToken()))) {
parameters.putString(
ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
previousTokenString);
// Don't log the actual access token, just its presence or absence.
addLoggingExtra(
ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
AppEventsConstants.EVENT_PARAM_VALUE_YES);
} else {
// The call to clear cookies will create the first instance of CookieSyncManager if
// necessary
Utility.clearFacebookCookies(loginClient.getActivity());
addLoggingExtra(
ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
AppEventsConstants.EVENT_PARAM_VALUE_NO);
}
WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
onWebDialogComplete(request, values, error);
}
};
e2e = LoginClient.getE2E();
addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);
FragmentActivity fragmentActivity = loginClient.getActivity();
WebDialog.Builder builder = new AuthDialogBuilder(
fragmentActivity,
request.getApplicationId(),
parameters)
.setE2E(e2e)
.setIsRerequest(request.isRerequest())
.setOnCompleteListener(listener)
.setTheme(FacebookSdk.getWebDialogTheme());
loginDialog = builder.build();
FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
dialogFragment.setRetainInstance(true);
dialogFragment.setDialog(loginDialog);
dialogFragment.show(fragmentActivity.getSupportFragmentManager(),
FacebookDialogFragment.TAG);
return true;
}
示例3: tryAuthorize
import com.facebook.internal.WebDialog; //导入依赖的package包/类
@Override
boolean tryAuthorize(final LoginClient.Request request) {
Bundle parameters = new Bundle();
if (!Utility.isNullOrEmpty(request.getPermissions())) {
String scope = TextUtils.join(",", request.getPermissions());
parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
}
DefaultAudience audience = request.getDefaultAudience();
parameters.putString(
ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());
AccessToken previousToken = AccessToken.getCurrentAccessToken();
String previousTokenString = previousToken != null ? previousToken.getToken() : null;
if (previousTokenString != null
&& (previousTokenString.equals(loadCookieToken()))) {
parameters.putString(
ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
previousTokenString);
// Don't log the actual access token, just its presence or absence.
addLoggingExtra(
ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
AppEventsConstants.EVENT_PARAM_VALUE_YES);
} else {
// The call to clear cookies will create the first instance of CookieSyncManager if
// necessary
Utility.clearFacebookCookies(loginClient.getActivity());
addLoggingExtra(
ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
AppEventsConstants.EVENT_PARAM_VALUE_NO);
}
WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
onWebDialogComplete(request, values, error);
}
};
e2e = LoginClient.getE2E();
addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);
FragmentActivity fragmentActivity = loginClient.getActivity();
WebDialog.Builder builder = new AuthDialogBuilder(
fragmentActivity,
request.getApplicationId(),
parameters)
.setE2E(e2e)
.setIsRerequest(request.isRerequest())
.setOnCompleteListener(listener);
loginDialog = builder.build();
FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
dialogFragment.setRetainInstance(true);
dialogFragment.setDialog(loginDialog);
dialogFragment.show(fragmentActivity.getSupportFragmentManager(),
FacebookDialogFragment.TAG);
return true;
}