The Profile Expression Kit was deprecated on September 30th, 2018.

Profile Expression Kit Android Documentation

Integrate with Facebook's Profile Picture and Profile Video upload flows from a 3rd party application. If you have the SDK, use the following steps:


1. Register an Application

2. Configure Facebook's Application Settings

3. Enable Deep-Linking from Facebook

4. Deep-Linking into Facebook

5. FAQ

1. Register an Application on the Facebook Developer Portal

If your application is not yet registered with Facebook click the button below or follow the more detailed instructions here. The generated application ID is shared across all platforms so this step only needs to be performed once.

Register an Application

2. Configure Facebook's Application Settings for Android

  1. Select your application from the Application Dashboard.
  2. Select Settings in the navigation pane.
  3. Select Add Platform and choose Android. You should now see a card in the Settings page similar to the image below.
  4. Fill in the Google Play Package Name field with the package name found in the AndroidManifest.xml of your application (the package attribute in the manifest element).
  5. Fill in the Key Hashes field. Instructions for how to determine the development and release key hashes can be found here and here respectively.
  6. Click Save Changes
Android Platform Settings Sample Screenshot

With regards to profile picture/profile video creation, Facebook deep-links into 3rd party applications via an Intent with the custom action name facebook.intent.action.PROFILE_MEDIA_CREATE. To be able to respond to deep-linking requests from Facebook, a 3rd party application needs only to set up an intent-filter, such as the one below, in their application's manifest.

<intent-filter>
  <action android:name="facebook.intent.action.PROFILE_MEDIA_CREATE"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

When Facebook deep-links into a 3rd party application it also passes along extra parameters for initial configuration of the UI when returning to Facebook and for logging purposes. While the 3rd party application doesn't need to concern itself with what these extras are, it should call the FacebookProfileMediaUtils.onDeepLinkFromFacebook(Bundle) SDK API upon being launched via deep-linking and upon activity recreation (such as after screen rotation or backgrounding the application with Do Not Keep Activities enabled for example). Example usage of this API can be seen below.

@Override
public void onCreate(Bundle savedInstanceState) {
  ...
  if (getIntent().getAction() != null &&
      getIntent().getAction).equals("facebook.intent.action.PROFILE_MEDIA_CREATE")) {
    FacebookProfileMediaUtils.onDeepLinkFromFacebook(getIntent().getExtras());
  }
  ...
}

It is worth noting that the following instructions for deep-linking from a 3rd party application to Facebook apply regardless of whether the 3rd party application was launched via deep-linking from Facebook or not; it makes no difference with regards to deep-linking into Facebook.

Deep-linking from a 3rd party application into Facebook is simply a matter of calling either the FacebookProfileMediaUtils.setProfilePicture(Context, String, String, Uri) or FacebookProfileMediaUtils.setProfileVideo(Context, String, String, Uri) SDK API (depending on whether you want to enter the Facebook profile picture or profile video creation flow). Example usage of the APIs can be found below. Note that the second and third arguments in both examples are the “Application ID” and “Google Play Package Name”; both of which are described in the Configure Facebook Application Settings for Android section of this documentation.

public void deepLinkIntoFacebookProfilePictureFlow(Context context, Uri pictureUri) {
  FacebookProfileMediaUtils.setProfilePicture(context, "facebook_developer_application_id", context.getPackageName(), pictureUri);
}
public void deepLinkIntoFacebookProfileVideoFlow(Context context, Uri videoUri) {
  FacebookProfileMediaUtils.setProfileVideo(context, "facebook_developer_application_id", context.getPackageName(), videoUri);
}

Before attempting to deep-link into Facebook it is strongly advised that 3rd party applications first query the deep-linking state of the installed Facebook application via the APIs in the SDK. Not calling these APIs may result in hard or silent crashes depending on the physical device and specific Android version. Sample code of how to query the profile picture and profile video deep-linking state can be found below. Note that there are numerous error codes provided by the FacebookProfileMediaUtils.canSetProfilePicture(Context) and FacebookProfileMediaUtils.canSetProfileVideo(Context) APIs and that the following code samples simplify these to boolean values.

public boolean canDeepLinkIntoFacebookProfilePictureFlow(Context context) {
  int deepLinkStatus = FacebookProfileMediaUtils.canSetProfilePicture(context);
  return deepLinkStatus == FacebookProfileMediaUtils.RESULT_CODE_CAN_DEEP_LINK;
}
public boolean canDeepLinkIntoFacebookProfileVideoFlow(Context context) {
  int deepLinkStatus = FacebookProfileMediaUtils.canSetProfileVideo(context);
  return deepLinkStatus == FacebookProfileMediaUtils.RESULT_CODE_CAN_DEEP_LINK;
}

5. FAQ

Why do I see a Toast with the message "Invalid Video" when I try to deep-link into Facebook?

This generic Toast will appear if the video Uri is null or the Uri path is null or if Android's MediaMetadataRetriever determines that the length of the video is 0. These issues are all typical of the video being corrupted and usually only require retrying the deep-link to resolve.

Why do I see a Toast with the message "Profile videos cannot exceed [XX] seconds" when i try to deep-link into Facebook?

Due to limitations dictated by the devices Facebook supports, there's a limit to how long of a video can be to be used in Facebook's profile video creation flow. This Toast will appear if the passed video exceeds that limit.

Why do I see a Toast with the message "Your video didn’t upload because the resolution is too low. Please select a video at least 180 pixels in size." when I try to deep-link into Facebook?

To maintain a certain level of video quality, Facebook has determined that it will only accept videos that are of above a certain width and height. If you see this Toast, the selected/recorded video did not pass this threshold.

Why does the Facebook picture/video upload fail when I deep-link into the Facebook profile picture/profile video creation flow?

This problem occurs when the Application ID and Key Hash that were set in the Android Platform Settings don't match with what is being passed to Facebook's server. To resolve this issue verify that the Application ID that's being passed to Facebook is the same as the one in the Android Platform Settings and verify that the Key Hash that's generated by your build is included in the Android Platform Settings field.

Why don't I see the Facebook application open when I'm trying to deep-link into it?

This occurs when the currently installed version of Facebook can't accept deep-linking. This can be avoided by querying the deep-linking status of the installed Facebook application (as described here) and adjusting the 3rd party application's behavior accordingly.