private static AppCall getAppCallFromActivityResult(int requestCode, int resultCode, Intent data) { UUID callId = NativeProtocol.getCallIdFromIntent(data); if (callId == null) { return null; } return AppCall.finishPendingCall(callId, requestCode); }
/** * Use this method to set a result on an Activity, where the result needs to be in the shape * of the native protocol used for native dialogs. */ public static Intent createProtocolResultIntent( Intent requestIntent, Bundle results, FacebookException error) { UUID callId = NativeProtocol.getCallIdFromIntent(requestIntent); if (callId == null) { return null; } Intent resultIntent = new Intent(); resultIntent.putExtra(EXTRA_PROTOCOL_VERSION, getProtocolVersionFromIntent(requestIntent)); Bundle bridgeArguments = new Bundle(); bridgeArguments.putString(BRIDGE_ARG_ACTION_ID_STRING, callId.toString()); if (error != null) { bridgeArguments.putBundle( BRIDGE_ARG_ERROR_BUNDLE, NativeProtocol.createBundleForException(error)); } resultIntent.putExtra(EXTRA_PROTOCOL_BRIDGE_ARGS, bridgeArguments); if (results != null) { resultIntent.putExtra(EXTRA_PROTOCOL_METHOD_RESULTS, results); } return resultIntent; }
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data, FacebookDialog.Callback facebookDialogCallback) { if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) { return false; } if (data == null) { // We understand the request code, but have no Intent. This can happen if the called Activity crashes // before it can be started; we treat this as a cancellation because we have no other information. cancelPendingAppCall(facebookDialogCallback); return true; } UUID callId = NativeProtocol.getCallIdFromIntent(data); // Was this result for the call we are waiting on? if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) { // Yes, we can handle it normally. FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data, facebookDialogCallback); } else { // No, send a cancellation error to the pending call and ignore the result, because we // don't know what to do with it. cancelPendingAppCall(facebookDialogCallback); } pendingFacebookDialogCall = null; return true; }