Java Code Examples for com.facebook.internal.NativeProtocol#createPlatformActivityIntent()

The following examples show how to use com.facebook.internal.NativeProtocol#createPlatformActivityIntent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FacebookDialog.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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;
}
 
Example 2
Source File: FacebookDialog.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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;
}
 
Example 3
Source File: FacebookDialog.java    From Klyph with MIT License 6 votes vote down vote up
@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;
}
 
Example 4
Source File: FacebookDialog.java    From Klyph with MIT License 6 votes vote down vote up
@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;
}
 
Example 5
Source File: FacebookDialog.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 6
Source File: FacebookDialog.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 7
Source File: FacebookDialog.java    From android-skeleton-project with MIT License 6 votes vote down vote up
/**
 * 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());
}
 
Example 8
Source File: FacebookDialog.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
/**
 * 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());
}
 
Example 9
Source File: FacebookDialog.java    From KlyphMessenger with MIT License 6 votes vote down vote up
@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;
}
 
Example 10
Source File: FacebookDialog.java    From KlyphMessenger with MIT License 6 votes vote down vote up
@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;
}
 
Example 11
Source File: FacebookDialog.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
/**
 * 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();

    String action = getActionForFeatures(getDialogFeatures());
    int protocolVersion = getProtocolVersionForNativeDialog(activity, action,
            getMinVersionForFeatures(getDialogFeatures()));

    Bundle extras = null;
    if (NativeProtocol.isVersionCompatibleWithBucketedIntent(protocolVersion)) {
        // Facebook app supports the new bucketed protocol
        extras = getMethodArguments();
    } else {
        // Facebook app only supports the old flat protocol
        extras = setBundleExtras(new Bundle());
    }

    Intent intent = NativeProtocol.createPlatformActivityIntent(
            activity,
            appCall.getCallId().toString(),
            action,
            protocolVersion,
            applicationName,
            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());
}
 
Example 12
Source File: FacebookDialog.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
/**
 * 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();

    String action = getActionForFeatures(getDialogFeatures());
    int protocolVersion = getProtocolVersionForNativeDialog(activity, action,
            getMinVersionForFeatures(getDialogFeatures()));

    Bundle extras = null;
    if (NativeProtocol.isVersionCompatibleWithBucketedIntent(protocolVersion)) {
        // Facebook app supports the new bucketed protocol
        extras = getMethodArguments();
    } else {
        // Facebook app only supports the old flat protocol
        extras = setBundleExtras(new Bundle());
    }

    Intent intent = NativeProtocol.createPlatformActivityIntent(
            activity,
            appCall.getCallId().toString(),
            action,
            protocolVersion,
            applicationName,
            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());
}