本文整理匯總了Java中com.facebook.internal.NativeProtocol類的典型用法代碼示例。如果您正苦於以下問題:Java NativeProtocol類的具體用法?Java NativeProtocol怎麽用?Java NativeProtocol使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NativeProtocol類屬於com.facebook.internal包,在下文中一共展示了NativeProtocol類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toJSONObjectForWeb
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
public static JSONObject toJSONObjectForWeb(
final ShareOpenGraphContent shareOpenGraphContent)
throws JSONException {
ShareOpenGraphAction action = shareOpenGraphContent.getAction();
return OpenGraphJSONUtility.toJSONObject(
action,
new OpenGraphJSONUtility.PhotoJSONProcessor() {
@Override
public JSONObject toJSONObject(SharePhoto photo) {
Uri photoUri = photo.getImageUrl();
JSONObject photoJSONObject = new JSONObject();
try {
photoJSONObject.put(
NativeProtocol.IMAGE_URL_KEY, photoUri.toString());
} catch (JSONException e) {
throw new FacebookException("Unable to attach images", e);
}
return photoJSONObject;
}
});
}
示例2: createAccessTokenFromNativeLogin
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
static AccessToken createAccessTokenFromNativeLogin(
Bundle bundle,
AccessTokenSource source,
String applicationId) {
Date expires = Utility.getBundleLongAsDate(
bundle, NativeProtocol.EXTRA_EXPIRES_SECONDS_SINCE_EPOCH, new Date(0));
ArrayList<String> permissions = bundle.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
String token = bundle.getString(NativeProtocol.EXTRA_ACCESS_TOKEN);
if (Utility.isNullOrEmpty(token)) {
return null;
}
String userId = bundle.getString(NativeProtocol.EXTRA_USER_ID);
return new AccessToken(
token,
applicationId,
userId,
permissions,
null,
source,
expires,
new Date());
}
示例3: tryAuthorize
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
@Override
boolean tryAuthorize(LoginClient.Request request) {
String e2e = LoginClient.getE2E();
Intent intent = NativeProtocol.createProxyAuthIntent(
loginClient.getActivity(),
request.getApplicationId(),
request.getPermissions(),
e2e,
request.isRerequest(),
request.hasPublishPermission(),
request.getDefaultAudience());
addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);
return tryIntent(intent, LoginClient.getLoginRequestCode());
}
示例4: handlePassThroughError
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
private void handlePassThroughError() {
Intent requestIntent = getIntent();
// The error we need to respond with is passed to us as method arguments.
Bundle errorResults = NativeProtocol.getMethodArgumentsFromIntent(requestIntent);
FacebookException exception = NativeProtocol.getExceptionFromErrorData(errorResults);
// Create a result intent that is formed based on the request intent
Intent resultIntent = NativeProtocol.createProtocolResultIntent(
requestIntent,
null,
exception);
setResult(RESULT_CANCELED, resultIntent);
finish();
}
示例5: cancelPendingAppCall
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
if (facebookDialogCallback != null) {
Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();
Intent cancelIntent = new Intent();
cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);
FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
}
pendingFacebookDialogCall = null;
}
示例6: handleActivityResult
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
/**
* Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
*
* @param context the Context that is handling the activity result
* @param appCall an PendingCall containing the call ID and original Intent used to launch the dialog
* @param requestCode the request code for the activity result
* @param data the result Intent
* @param callback a callback to call after parsing the results
* @return true if the activity result was handled, false if not
*/
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
Callback callback) {
if (requestCode != appCall.getRequestCode()) {
return false;
}
if (attachmentStore != null) {
attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
}
if (callback != null) {
if (NativeProtocol.isErrorResult(data)) {
Exception error = NativeProtocol.getErrorFromResult(data);
callback.onError(appCall, error, data.getExtras());
} else {
callback.onComplete(appCall, data.getExtras());
}
}
return true;
}
示例7: getEventName
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
static private String getEventName(String action, boolean hasPhotos) {
String eventName;
if (action.equals(NativeProtocol.ACTION_FEED_DIALOG)) {
eventName = hasPhotos ?
AnalyticsEvents.EVENT_NATIVE_DIALOG_TYPE_PHOTO_SHARE :
AnalyticsEvents.EVENT_NATIVE_DIALOG_TYPE_SHARE;
} else if (action.equals(NativeProtocol.ACTION_MESSAGE_DIALOG)) {
eventName = hasPhotos ?
AnalyticsEvents.EVENT_NATIVE_DIALOG_TYPE_PHOTO_MESSAGE :
AnalyticsEvents.EVENT_NATIVE_DIALOG_TYPE_MESSAGE;
} else if (action.equals(NativeProtocol.ACTION_OGACTIONPUBLISH_DIALOG)) {
eventName = AnalyticsEvents.EVENT_NATIVE_DIALOG_TYPE_OG_SHARE;
} else if (action.equals(NativeProtocol.ACTION_OGMESSAGEPUBLISH_DIALOG)) {
eventName = AnalyticsEvents.EVENT_NATIVE_DIALOG_TYPE_OG_MESSAGE;
} else {
throw new FacebookException("An unspecified action was presented");
}
return eventName;
}
示例8: build
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
/**
* Constructs a FacebookDialog with an Intent that is correctly populated to present the dialog within
* the Facebook application.
*
* @return a FacebookDialog instance
*/
public FacebookDialog build() {
validate();
Bundle extras = new Bundle();
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_ID, applicationId);
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_NAME, applicationName);
extras = setBundleExtras(extras);
String action = getActionForFeatures(getDialogFeatures());
int protocolVersion = getProtocolVersionForNativeDialog(activity, action,
getMinVersionForFeatures(getDialogFeatures()));
Intent intent = NativeProtocol.createPlatformActivityIntent(activity, action, protocolVersion, extras);
if (intent == null) {
logDialogActivity(activity, fragment,
getEventName(action, extras.containsKey(NativeProtocol.EXTRA_PHOTOS)),
AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_FAILED);
throw new FacebookException(
"Unable to create Intent; this likely means the Facebook app is not installed.");
}
appCall.setRequestIntent(intent);
return new FacebookDialog(activity, fragment, appCall, getOnPresentCallback());
}
示例9: setBundleExtras
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
@Override
Bundle setBundleExtras(Bundle extras) {
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_ID, applicationId);
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_NAME, applicationName);
putExtra(extras, NativeProtocol.EXTRA_TITLE, name);
putExtra(extras, NativeProtocol.EXTRA_SUBTITLE, caption);
putExtra(extras, NativeProtocol.EXTRA_DESCRIPTION, description);
putExtra(extras, NativeProtocol.EXTRA_LINK, link);
putExtra(extras, NativeProtocol.EXTRA_IMAGE, picture);
putExtra(extras, NativeProtocol.EXTRA_PLACE_TAG, place);
putExtra(extras, NativeProtocol.EXTRA_TITLE, name);
putExtra(extras, NativeProtocol.EXTRA_REF, ref);
extras.putBoolean(NativeProtocol.EXTRA_DATA_FAILURES_FATAL, dataErrorsFatal);
if (!Utility.isNullOrEmpty(friends)) {
extras.putStringArrayList(NativeProtocol.EXTRA_FRIEND_TAGS, friends);
}
return extras;
}
示例10: updateActionAttachmentUrls
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
private void updateActionAttachmentUrls(List<String> attachmentUrls, boolean isUserGenerated) {
List<JSONObject> attachments = action.getImage();
if (attachments == null) {
attachments = new ArrayList<JSONObject>(attachmentUrls.size());
}
for (String url : attachmentUrls) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put(NativeProtocol.IMAGE_URL_KEY, url);
if (isUserGenerated) {
jsonObject.put(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
}
} catch (JSONException e) {
throw new FacebookException("Unable to attach images", e);
}
attachments.add(jsonObject);
}
action.setImage(attachments);
}
示例11: tryAuthorize
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
@Override
boolean tryAuthorize(AuthorizationRequest request) {
applicationId = request.getApplicationId();
Intent intent = NativeProtocol.createLoginDialog20121101Intent(context, request.getApplicationId(),
new ArrayList<String>(request.getPermissions()),
request.getDefaultAudience().getNativeProtocolAudience());
if (intent == null) {
return false;
}
callId = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
addLoggingExtra(EVENT_EXTRAS_APP_CALL_ID, callId);
addLoggingExtra(EVENT_EXTRAS_PROTOCOL_VERSION,
intent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
addLoggingExtra(EVENT_EXTRAS_PERMISSIONS,
TextUtils.join(",", intent.getStringArrayListExtra(NativeProtocol.EXTRA_PERMISSIONS)));
addLoggingExtra(EVENT_EXTRAS_WRITE_PRIVACY, intent.getStringExtra(NativeProtocol.EXTRA_WRITE_PRIVACY));
logEvent(AnalyticsEvents.EVENT_NATIVE_LOGIN_DIALOG_START,
AnalyticsEvents.PARAMETER_NATIVE_LOGIN_DIALOG_START_TIME, callId);
return tryIntent(intent, request.getRequestCode());
}
示例12: handleBuild
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
@Override
Intent handleBuild(Bundle extras) {
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_ID, applicationId);
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_NAME, applicationName);
putExtra(extras, NativeProtocol.EXTRA_TITLE, name);
putExtra(extras, NativeProtocol.EXTRA_SUBTITLE, caption);
putExtra(extras, NativeProtocol.EXTRA_DESCRIPTION, description);
putExtra(extras, NativeProtocol.EXTRA_LINK, link);
putExtra(extras, NativeProtocol.EXTRA_IMAGE, picture);
putExtra(extras, NativeProtocol.EXTRA_PLACE_TAG, place);
putExtra(extras, NativeProtocol.EXTRA_TITLE, name);
putExtra(extras, NativeProtocol.EXTRA_REF, ref);
extras.putBoolean(NativeProtocol.EXTRA_DATA_FAILURES_FATAL, dataErrorsFatal);
if (!Utility.isNullOrEmpty(friends)) {
extras.putStringArrayList(NativeProtocol.EXTRA_FRIEND_TAGS, friends);
}
int protocolVersion = getProtocolVersionForNativeDialog(activity, MIN_NATIVE_SHARE_PROTOCOL_VERSION);
Intent intent = NativeProtocol.createPlatformActivityIntent(activity, NativeProtocol.ACTION_FEED_DIALOG,
protocolVersion, extras);
return intent;
}
示例13: build
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
/**
* Constructs a FacebookDialog with an Intent that is correctly populated to present the dialog within
* the Facebook application.
* @return a FacebookDialog instance
*/
public FacebookDialog build() {
validate();
Bundle extras = new Bundle();
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_ID, applicationId);
putExtra(extras, NativeProtocol.EXTRA_APPLICATION_NAME, applicationName);
Intent intent = handleBuild(extras);
if (intent == null) {
throw new FacebookException("Unable to create Intent; this likely means the Facebook app is not installed.");
}
appCall.setRequestIntent(intent);
return new FacebookDialog(activity, fragment, appCall, getOnPresentCallback());
}
示例14: handleBuild
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
@Override
Intent handleBuild(Bundle extras) {
putExtra(extras, NativeProtocol.EXTRA_PREVIEW_PROPERTY_NAME, previewPropertyName);
putExtra(extras, NativeProtocol.EXTRA_ACTION_TYPE, actionType);
extras.putBoolean(NativeProtocol.EXTRA_DATA_FAILURES_FATAL, dataErrorsFatal);
JSONObject jsonAction = action.getInnerJSONObject();
jsonAction = flattenChildrenOfGraphObject(jsonAction);
String jsonString = jsonAction.toString();
putExtra(extras, NativeProtocol.EXTRA_ACTION, jsonString);
int protocolVersion = getProtocolVersionForNativeDialog(activity, MIN_NATIVE_SHARE_PROTOCOL_VERSION);
Intent intent = NativeProtocol.createPlatformActivityIntent(activity,
NativeProtocol.ACTION_OGACTIONPUBLISH_DIALOG, protocolVersion, extras);
return intent;
}
示例15: onReceive
import com.facebook.internal.NativeProtocol; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
String appCallId = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
String action = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION);
if (appCallId != null && action != null) {
Bundle extras = intent.getExtras();
if (NativeProtocol.isErrorResult(intent)) {
onFailedAppCall(appCallId, action, extras);
} else {
onSuccessfulAppCall(appCallId, action, extras);
}
}
}