Sharing on Android


This guide details how to enable sharing from your app to TikTok. After sharing successfully to TikTok, users will see your app's name in TikTok feed.

Note: The minimum TikTok version supporting sharing is 11.3.0.


Before you can share to TikTok from your App, make sure you have obtained a Client Key from TikTok and installed the TikTok SDK to your Android project. For details on these requirements, see Getting started.

Detailed Steps

Edit your Application

First you need to initialize TikTokOpenApiFactory by using client key in your custom Application.

public void onCreate() {
    String clientkey = "[CLIENT_KEY]";
    TikTokOpenApiFactory.init(new TikTokOpenConfig(clientkey));

Edit Your Manifest

  1. Open the /app/manifest/AndroidManifest.xml file.
  2. Register TikTokEntryActivity for receiving callbacks in Manifest. If you have customized an activity to receive callbacks, you may skip this step.
//If you have customized activity to receive callnacks,you can skip the step

Send Share Request

  1. Create a TiktokOpenApi to send share request.
  2. Build share content for images/videos into the TikTokMediaContent model.
  3. Create Share.Request instance and set required parameters: request.mMediaContent = [TikTokMediaContent].
  4. Call method Share() in TiktokOpenApi .
//1.create TiktokOpenApi
TiktokOpenApi tiktokOpenApi= TikTokOpenApiFactory.create(this);

Share.Request request = new Share.Request();
//initialize the resource path, please provide absolute path
ArrayList<String> mUri = new ArrayList<>();
mUri.add ...

// share content for photos/videos into TikTokMediaContent
  VideoObject videoObject = new VideoObject();
  videoObject.mVideoPaths = mUri;
  MediaContent content = new MediaContent();
  content.mMediaObject = videoObject;
//3.set required parameters
  request.mMediaContent = content;

// or share multi-picture,here the size of mUri must >=2
   ImageObject imageObject = new ImageObject();
   imageObject.mImagePaths = mUri;
   MediaContent mediaContent = new MediaContent();
   mediaContent.mMediaObject = imageObject;
   request.mMediaContent = mediaContent;

//4.start share

After a successful sharing session, a Dialog will prompt for the user to choose Back to your App or Stay in TikTok.

If you want to receive callbacks when people stay in TikTok , please register to receive a broadcast :

public static final String ACTION_STAY_IN_TT = "";

Parameters in Share.Request

mMediaContentYou can build share content for videos or photos using following models:
1.multi-Image: see ImageObjectmodel .
Note: The size of Images must more than one and up to 12.
2.single-video\multi-video: see VideoObjectmodel.
Then assign required parameter as request.mMediaContent = [MediaContent];
callerLocalEntrySet customized callback Activity by using request.callerLocalEntry = ""; If this parameter is not set, TikTok will callback TikTokEntryActivity in default.

Receive Callbacks

We provides two ways for you to receive the callback data from TikTok.

  1. Create new activity named "TikTokEntryActivity" in your app and implement TikTokApiEventHandler interface. Note: The path of the activity should be your "package name" + .tiktokapi.TikTokEntryActivity. For example, "com.tiktok.opensdk.tiktokapi.TikTokEntryActivity".

    The following example shows how to use the TikTokEntryActivity to receive the callback data.

    class TikTokEntryActivity extends Activity implements TikTokApiEventHandler {
       TiktokOpenApi ttOpenApi;
       public void onCreate(@Nullable Bundle savedInstanceState) {
           ttOpenApi= TikTokOpenApiFactory.create(this);
           ttOpenApi.handleIntent(getIntent(),this); // receive and parse callback
       public void onReq(BaseReq req) {
       public void onResp(BaseResp resp) {
           if (resp.getType() == TikTokConstants.ModeType.SHARE_CONTENT_TO_TT_RESP)  {
               Share.Response response = (Share.Response) resp;
               Toast.makeText(this, " code:" + response.errorCode + " errorMessage:" + response.errorMsg, Toast.LENGTH_SHORT).show();
       public void onErrorIntent(@Nullable Intent intent) {
           Toast.makeText(this, "Intent Error", Toast.LENGTH_LONG).show();
  2. You can also customize your own activity to receive the callback; just implement the interface IApiEventHandler and set your activity path by using parameter "callerLocalEntry".

// request.callerLocalEntry = "";

In the table below, each row represents error code. For further information please see the CommonConstants.

-1Unknown error
-2User cancelled
-3Send failed

If the error code does not make it easy for you to locate a specific error, you can use 'response.subErrorCode` for detail message. SDK version need or higher and tiktok version need 14.4.0 or higher.

20002Params parsing error, media resource type difference you pass
20003Not enough permissions to operation.
20004User not login
20005TikTok has no album permissions
20006TikTok Network error
20007Video length doesn't meet requirements
20008Photo doesn't meet requirements
20010Processing photo resources faild
20011Video resolution doesn't meet requirements
20012Video format is not supported
20013Sharing canceled
20015Users store shared content for draft or user accounts are not allowed to post videos
22001Unsupported resolution

Requirements for Media

  • For Video:
    • Minimum video duration must be 3 seconds
    • Supported video media type: .mp4
    • The Minimum of the frame size should be no more than 1100
  • For multi-Video:
    • The number of Videos can be no more than 12.
  • For multi-Image:
    • The number of images should be more than 1 and up to 12.
  • Videos cannot contain brand logos or watermarks. Violating this guideline will lead to videos being deleted or accounts being banned. Make sure your applications share content without watermarks or brand logos.

When you upgrade sdk to version,there are some changes you need to make.

How to integrate?

 dependencies {

        implementation 'com.bytedance.ies.ugc.aweme:opensdk-oversea-external:'
         implementation 'com.bytedance.ies.ugc.aweme:opensdk-common:'

Compared to the old version of the SDK, the difference is the new SDK needs to integrate two libraries.

the class name of these classes have been changed, you need to change you code.


the package name of these classes have been changed, you need to reimport these classes

Class NamePackageName BeforePackageName After